This commit is contained in:
6
frontend/node_modules/@reduxjs/toolkit/dist/cjs/index.js
generated
vendored
Normal file
6
frontend/node_modules/@reduxjs/toolkit/dist/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./redux-toolkit.production.min.cjs')
|
||||
} else {
|
||||
module.exports = require('./redux-toolkit.development.cjs')
|
||||
}
|
||||
2387
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs
generated
vendored
Normal file
2387
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs
generated
vendored
Normal file
3
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2662
frontend/node_modules/@reduxjs/toolkit/dist/index.d.mts
generated
vendored
Normal file
2662
frontend/node_modules/@reduxjs/toolkit/dist/index.d.mts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2662
frontend/node_modules/@reduxjs/toolkit/dist/index.d.ts
generated
vendored
Normal file
2662
frontend/node_modules/@reduxjs/toolkit/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/index.js
generated
vendored
Normal file
6
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./rtk-query.production.min.cjs')
|
||||
} else {
|
||||
module.exports = require('./rtk-query.development.cjs')
|
||||
}
|
||||
3087
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs
generated
vendored
Normal file
3087
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs
generated
vendored
Normal file
2
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2954
frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.mts
generated
vendored
Normal file
2954
frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.mts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2954
frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.ts
generated
vendored
Normal file
2954
frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/index.js
generated
vendored
Normal file
6
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./rtk-query-react.production.min.cjs')
|
||||
} else {
|
||||
module.exports = require('./rtk-query-react.development.cjs')
|
||||
}
|
||||
748
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs
generated
vendored
Normal file
748
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs
generated
vendored
Normal file
@@ -0,0 +1,748 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/query/react/index.ts
|
||||
var react_exports = {};
|
||||
__export(react_exports, {
|
||||
ApiProvider: () => ApiProvider,
|
||||
UNINITIALIZED_VALUE: () => UNINITIALIZED_VALUE,
|
||||
createApi: () => createApi,
|
||||
reactHooksModule: () => reactHooksModule,
|
||||
reactHooksModuleName: () => reactHooksModuleName
|
||||
});
|
||||
module.exports = __toCommonJS(react_exports);
|
||||
|
||||
// src/query/react/rtkqImports.ts
|
||||
var import_query = require("@reduxjs/toolkit/query");
|
||||
|
||||
// src/query/react/module.ts
|
||||
var import_toolkit2 = require("@reduxjs/toolkit");
|
||||
var import_react_redux2 = require("react-redux");
|
||||
var import_reselect = require("reselect");
|
||||
|
||||
// src/query/utils/capitalize.ts
|
||||
function capitalize(str) {
|
||||
return str.replace(str[0], str[0].toUpperCase());
|
||||
}
|
||||
|
||||
// src/query/utils/countObjectKeys.ts
|
||||
function countObjectKeys(obj) {
|
||||
let count = 0;
|
||||
for (const _key in obj) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// src/query/endpointDefinitions.ts
|
||||
var ENDPOINT_QUERY = "query" /* query */;
|
||||
var ENDPOINT_MUTATION = "mutation" /* mutation */;
|
||||
var ENDPOINT_INFINITEQUERY = "infinitequery" /* infinitequery */;
|
||||
function isQueryDefinition(e) {
|
||||
return e.type === ENDPOINT_QUERY;
|
||||
}
|
||||
function isMutationDefinition(e) {
|
||||
return e.type === ENDPOINT_MUTATION;
|
||||
}
|
||||
function isInfiniteQueryDefinition(e) {
|
||||
return e.type === ENDPOINT_INFINITEQUERY;
|
||||
}
|
||||
|
||||
// src/query/tsHelpers.ts
|
||||
function safeAssign(target, ...args) {
|
||||
return Object.assign(target, ...args);
|
||||
}
|
||||
|
||||
// src/query/react/buildHooks.ts
|
||||
var import_toolkit = require("@reduxjs/toolkit");
|
||||
|
||||
// src/query/react/reactImports.ts
|
||||
var import_react = require("react");
|
||||
|
||||
// src/query/react/reactReduxImports.ts
|
||||
var import_react_redux = require("react-redux");
|
||||
|
||||
// src/query/react/constants.ts
|
||||
var UNINITIALIZED_VALUE = Symbol();
|
||||
|
||||
// src/query/react/useSerializedStableValue.ts
|
||||
function useStableQueryArgs(queryArgs) {
|
||||
const cache = (0, import_react.useRef)(queryArgs);
|
||||
const copy = (0, import_react.useMemo)(() => (0, import_query.copyWithStructuralSharing)(cache.current, queryArgs), [queryArgs]);
|
||||
(0, import_react.useEffect)(() => {
|
||||
if (cache.current !== copy) {
|
||||
cache.current = copy;
|
||||
}
|
||||
}, [copy]);
|
||||
return copy;
|
||||
}
|
||||
|
||||
// src/query/react/useShallowStableValue.ts
|
||||
function useShallowStableValue(value) {
|
||||
const cache = (0, import_react.useRef)(value);
|
||||
(0, import_react.useEffect)(() => {
|
||||
if (!(0, import_react_redux.shallowEqual)(cache.current, value)) {
|
||||
cache.current = value;
|
||||
}
|
||||
}, [value]);
|
||||
return (0, import_react_redux.shallowEqual)(cache.current, value) ? cache.current : value;
|
||||
}
|
||||
|
||||
// src/query/react/buildHooks.ts
|
||||
var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
||||
var isDOM = /* @__PURE__ */ canUseDOM();
|
||||
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
||||
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
||||
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? import_react.useLayoutEffect : import_react.useEffect;
|
||||
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
||||
var noPendingQueryStateSelector = (selected) => {
|
||||
if (selected.isUninitialized) {
|
||||
return {
|
||||
...selected,
|
||||
isUninitialized: false,
|
||||
isFetching: true,
|
||||
isLoading: selected.data !== void 0 ? false : true,
|
||||
// This is the one place where we still have to use `QueryStatus` as an enum,
|
||||
// since it's the only reference in the React package and not in the core.
|
||||
status: import_query.QueryStatus.pending
|
||||
};
|
||||
}
|
||||
return selected;
|
||||
};
|
||||
function pick(obj, ...keys) {
|
||||
const ret = {};
|
||||
keys.forEach((key) => {
|
||||
ret[key] = obj[key];
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
|
||||
function buildHooks({
|
||||
api,
|
||||
moduleOptions: {
|
||||
batch,
|
||||
hooks: {
|
||||
useDispatch,
|
||||
useSelector,
|
||||
useStore
|
||||
},
|
||||
unstable__sideEffectsInRender,
|
||||
createSelector
|
||||
},
|
||||
serializeQueryArgs,
|
||||
context
|
||||
}) {
|
||||
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : import_react.useEffect;
|
||||
const unsubscribePromiseRef = (ref) => ref.current?.unsubscribe?.();
|
||||
const endpointDefinitions = context.endpointDefinitions;
|
||||
return {
|
||||
buildQueryHooks,
|
||||
buildInfiniteQueryHooks,
|
||||
buildMutationHook,
|
||||
usePrefetch
|
||||
};
|
||||
function queryStatePreSelector(currentState, lastResult, queryArgs) {
|
||||
if (lastResult?.endpointName && currentState.isUninitialized) {
|
||||
const {
|
||||
endpointName
|
||||
} = lastResult;
|
||||
const endpointDefinition = endpointDefinitions[endpointName];
|
||||
if (queryArgs !== import_query.skipToken && serializeQueryArgs({
|
||||
queryArgs: lastResult.originalArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
}) === serializeQueryArgs({
|
||||
queryArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
})) lastResult = void 0;
|
||||
}
|
||||
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
||||
if (data === void 0) data = currentState.data;
|
||||
const hasData = data !== void 0;
|
||||
const isFetching = currentState.isLoading;
|
||||
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
||||
const isSuccess = currentState.isSuccess || hasData && (isFetching && !lastResult?.isError || currentState.isUninitialized);
|
||||
return {
|
||||
...currentState,
|
||||
data,
|
||||
currentData: currentState.data,
|
||||
isFetching,
|
||||
isLoading,
|
||||
isSuccess
|
||||
};
|
||||
}
|
||||
function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
|
||||
if (lastResult?.endpointName && currentState.isUninitialized) {
|
||||
const {
|
||||
endpointName
|
||||
} = lastResult;
|
||||
const endpointDefinition = endpointDefinitions[endpointName];
|
||||
if (queryArgs !== import_query.skipToken && serializeQueryArgs({
|
||||
queryArgs: lastResult.originalArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
}) === serializeQueryArgs({
|
||||
queryArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
})) lastResult = void 0;
|
||||
}
|
||||
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
||||
if (data === void 0) data = currentState.data;
|
||||
const hasData = data !== void 0;
|
||||
const isFetching = currentState.isLoading;
|
||||
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
||||
const isSuccess = currentState.isSuccess || isFetching && hasData;
|
||||
return {
|
||||
...currentState,
|
||||
data,
|
||||
currentData: currentState.data,
|
||||
isFetching,
|
||||
isLoading,
|
||||
isSuccess
|
||||
};
|
||||
}
|
||||
function usePrefetch(endpointName, defaultOptions) {
|
||||
const dispatch = useDispatch();
|
||||
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
||||
return (0, import_react.useCallback)((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
|
||||
...stableDefaultOptions,
|
||||
...options
|
||||
})), [endpointName, dispatch, stableDefaultOptions]);
|
||||
}
|
||||
function useQuerySubscriptionCommonImpl(endpointName, arg, {
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
refetchOnMountOrArgChange,
|
||||
skip = false,
|
||||
pollingInterval = 0,
|
||||
skipPollingIfUnfocused = false,
|
||||
...rest
|
||||
} = {}) {
|
||||
const {
|
||||
initiate
|
||||
} = api.endpoints[endpointName];
|
||||
const dispatch = useDispatch();
|
||||
const subscriptionSelectorsRef = (0, import_react.useRef)(void 0);
|
||||
if (!subscriptionSelectorsRef.current) {
|
||||
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
||||
if (true) {
|
||||
if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
|
||||
throw new Error(false ? _formatProdErrorMessage(37) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
|
||||
You must add the middleware for RTK-Query to function correctly!`);
|
||||
}
|
||||
}
|
||||
subscriptionSelectorsRef.current = returnedValue;
|
||||
}
|
||||
const stableArg = useStableQueryArgs(skip ? import_query.skipToken : arg);
|
||||
const stableSubscriptionOptions = useShallowStableValue({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval,
|
||||
skipPollingIfUnfocused
|
||||
});
|
||||
const initialPageParam = rest.initialPageParam;
|
||||
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
||||
const refetchCachedPages = rest.refetchCachedPages;
|
||||
const stableRefetchCachedPages = useShallowStableValue(refetchCachedPages);
|
||||
const promiseRef = (0, import_react.useRef)(void 0);
|
||||
let {
|
||||
queryCacheKey,
|
||||
requestId
|
||||
} = promiseRef.current || {};
|
||||
let currentRenderHasSubscription = false;
|
||||
if (queryCacheKey && requestId) {
|
||||
currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
|
||||
}
|
||||
const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
|
||||
usePossiblyImmediateEffect(() => {
|
||||
if (subscriptionRemoved) {
|
||||
promiseRef.current = void 0;
|
||||
}
|
||||
}, [subscriptionRemoved]);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
const lastPromise = promiseRef.current;
|
||||
if (typeof process !== "undefined" && false) {
|
||||
console.log(subscriptionRemoved);
|
||||
}
|
||||
if (stableArg === import_query.skipToken) {
|
||||
lastPromise?.unsubscribe();
|
||||
promiseRef.current = void 0;
|
||||
return;
|
||||
}
|
||||
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
||||
if (!lastPromise || lastPromise.arg !== stableArg) {
|
||||
lastPromise?.unsubscribe();
|
||||
const promise = dispatch(initiate(stableArg, {
|
||||
subscriptionOptions: stableSubscriptionOptions,
|
||||
forceRefetch: refetchOnMountOrArgChange,
|
||||
...isInfiniteQueryDefinition(endpointDefinitions[endpointName]) ? {
|
||||
initialPageParam: stableInitialPageParam,
|
||||
refetchCachedPages: stableRefetchCachedPages
|
||||
} : {}
|
||||
}));
|
||||
promiseRef.current = promise;
|
||||
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
||||
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
|
||||
}
|
||||
}, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, stableRefetchCachedPages, endpointName]);
|
||||
return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
|
||||
}
|
||||
function buildUseQueryState(endpointName, preSelector) {
|
||||
const useQueryState = (arg, {
|
||||
skip = false,
|
||||
selectFromResult
|
||||
} = {}) => {
|
||||
const {
|
||||
select
|
||||
} = api.endpoints[endpointName];
|
||||
const stableArg = useStableQueryArgs(skip ? import_query.skipToken : arg);
|
||||
const lastValue = (0, import_react.useRef)(void 0);
|
||||
const selectDefaultResult = (0, import_react.useMemo)(() => (
|
||||
// Normally ts-ignores are bad and should be avoided, but we're
|
||||
// already casting this selector to be `Selector<any>` anyway,
|
||||
// so the inconsistencies don't matter here
|
||||
// @ts-ignore
|
||||
createSelector([
|
||||
// @ts-ignore
|
||||
select(stableArg),
|
||||
(_, lastResult) => lastResult,
|
||||
(_) => stableArg
|
||||
], preSelector, {
|
||||
memoizeOptions: {
|
||||
resultEqualityCheck: import_react_redux.shallowEqual
|
||||
}
|
||||
})
|
||||
), [select, stableArg]);
|
||||
const querySelector = (0, import_react.useMemo)(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
||||
devModeChecks: {
|
||||
identityFunctionCheck: "never"
|
||||
}
|
||||
}) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
|
||||
const currentState = useSelector((state) => querySelector(state, lastValue.current), import_react_redux.shallowEqual);
|
||||
const store = useStore();
|
||||
const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
lastValue.current = newLastValue;
|
||||
}, [newLastValue]);
|
||||
return currentState;
|
||||
};
|
||||
return useQueryState;
|
||||
}
|
||||
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
||||
(0, import_react.useEffect)(() => {
|
||||
return () => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = void 0;
|
||||
};
|
||||
}, [promiseRef]);
|
||||
}
|
||||
function refetchOrErrorIfUnmounted(promiseRef) {
|
||||
if (!promiseRef.current) throw new Error(false ? _formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
|
||||
return promiseRef.current.refetch();
|
||||
}
|
||||
function buildQueryHooks(endpointName) {
|
||||
const useQuerySubscription = (arg, options = {}) => {
|
||||
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
||||
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
||||
return (0, import_react.useMemo)(() => ({
|
||||
/**
|
||||
* A method to manually refetch data for the query
|
||||
*/
|
||||
refetch: () => refetchOrErrorIfUnmounted(promiseRef)
|
||||
}), [promiseRef]);
|
||||
};
|
||||
const useLazyQuerySubscription = ({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval = 0,
|
||||
skipPollingIfUnfocused = false
|
||||
} = {}) => {
|
||||
const {
|
||||
initiate
|
||||
} = api.endpoints[endpointName];
|
||||
const dispatch = useDispatch();
|
||||
const [arg, setArg] = (0, import_react.useState)(UNINITIALIZED_VALUE);
|
||||
const promiseRef = (0, import_react.useRef)(void 0);
|
||||
const stableSubscriptionOptions = useShallowStableValue({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval,
|
||||
skipPollingIfUnfocused
|
||||
});
|
||||
usePossiblyImmediateEffect(() => {
|
||||
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
||||
if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
||||
promiseRef.current?.updateSubscriptionOptions(stableSubscriptionOptions);
|
||||
}
|
||||
}, [stableSubscriptionOptions]);
|
||||
const subscriptionOptionsRef = (0, import_react.useRef)(stableSubscriptionOptions);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
||||
}, [stableSubscriptionOptions]);
|
||||
const trigger = (0, import_react.useCallback)(function(arg2, preferCacheValue = false) {
|
||||
let promise;
|
||||
batch(() => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = promise = dispatch(initiate(arg2, {
|
||||
subscriptionOptions: subscriptionOptionsRef.current,
|
||||
forceRefetch: !preferCacheValue
|
||||
}));
|
||||
setArg(arg2);
|
||||
});
|
||||
return promise;
|
||||
}, [dispatch, initiate]);
|
||||
const reset = (0, import_react.useCallback)(() => {
|
||||
if (promiseRef.current?.queryCacheKey) {
|
||||
dispatch(api.internalActions.removeQueryResult({
|
||||
queryCacheKey: promiseRef.current?.queryCacheKey
|
||||
}));
|
||||
}
|
||||
}, [dispatch]);
|
||||
(0, import_react.useEffect)(() => {
|
||||
return () => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
};
|
||||
}, []);
|
||||
(0, import_react.useEffect)(() => {
|
||||
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
||||
trigger(arg, true);
|
||||
}
|
||||
}, [arg, trigger]);
|
||||
return (0, import_react.useMemo)(() => [trigger, arg, {
|
||||
reset
|
||||
}], [trigger, arg, reset]);
|
||||
};
|
||||
const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
|
||||
return {
|
||||
useQueryState,
|
||||
useQuerySubscription,
|
||||
useLazyQuerySubscription,
|
||||
useLazyQuery(options) {
|
||||
const [trigger, arg, {
|
||||
reset
|
||||
}] = useLazyQuerySubscription(options);
|
||||
const queryStateResults = useQueryState(arg, {
|
||||
...options,
|
||||
skip: arg === UNINITIALIZED_VALUE
|
||||
});
|
||||
const info = (0, import_react.useMemo)(() => ({
|
||||
lastArg: arg
|
||||
}), [arg]);
|
||||
return (0, import_react.useMemo)(() => [trigger, {
|
||||
...queryStateResults,
|
||||
reset
|
||||
}, info], [trigger, queryStateResults, reset, info]);
|
||||
},
|
||||
useQuery(arg, options) {
|
||||
const querySubscriptionResults = useQuerySubscription(arg, options);
|
||||
const queryStateResults = useQueryState(arg, {
|
||||
selectFromResult: arg === import_query.skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
||||
...options
|
||||
});
|
||||
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
||||
(0, import_react.useDebugValue)(debugValue);
|
||||
return (0, import_react.useMemo)(() => ({
|
||||
...queryStateResults,
|
||||
...querySubscriptionResults
|
||||
}), [queryStateResults, querySubscriptionResults]);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildInfiniteQueryHooks(endpointName) {
|
||||
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
||||
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
||||
const subscriptionOptionsRef = (0, import_react.useRef)(stableSubscriptionOptions);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
||||
}, [stableSubscriptionOptions]);
|
||||
const hookRefetchCachedPages = options.refetchCachedPages;
|
||||
const stableHookRefetchCachedPages = useShallowStableValue(hookRefetchCachedPages);
|
||||
const trigger = (0, import_react.useCallback)(function(arg2, direction) {
|
||||
let promise;
|
||||
batch(() => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = promise = dispatch(initiate(arg2, {
|
||||
subscriptionOptions: subscriptionOptionsRef.current,
|
||||
direction
|
||||
}));
|
||||
});
|
||||
return promise;
|
||||
}, [promiseRef, dispatch, initiate]);
|
||||
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
||||
const stableArg = useStableQueryArgs(options.skip ? import_query.skipToken : arg);
|
||||
const refetch = (0, import_react.useCallback)((options2) => {
|
||||
if (!promiseRef.current) throw new Error(false ? _formatProdErrorMessage3(38) : "Cannot refetch a query that has not been started yet.");
|
||||
const mergedOptions = {
|
||||
refetchCachedPages: options2?.refetchCachedPages ?? stableHookRefetchCachedPages
|
||||
};
|
||||
return promiseRef.current.refetch(mergedOptions);
|
||||
}, [promiseRef, stableHookRefetchCachedPages]);
|
||||
return (0, import_react.useMemo)(() => {
|
||||
const fetchNextPage = () => {
|
||||
return trigger(stableArg, "forward");
|
||||
};
|
||||
const fetchPreviousPage = () => {
|
||||
return trigger(stableArg, "backward");
|
||||
};
|
||||
return {
|
||||
trigger,
|
||||
/**
|
||||
* A method to manually refetch data for the query
|
||||
*/
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage
|
||||
};
|
||||
}, [refetch, trigger, stableArg]);
|
||||
};
|
||||
const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
|
||||
return {
|
||||
useInfiniteQueryState,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQuery(arg, options) {
|
||||
const {
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage
|
||||
} = useInfiniteQuerySubscription(arg, options);
|
||||
const queryStateResults = useInfiniteQueryState(arg, {
|
||||
selectFromResult: arg === import_query.skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
||||
...options
|
||||
});
|
||||
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
||||
(0, import_react.useDebugValue)(debugValue);
|
||||
return (0, import_react.useMemo)(() => ({
|
||||
...queryStateResults,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage,
|
||||
refetch
|
||||
}), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildMutationHook(name) {
|
||||
return ({
|
||||
selectFromResult,
|
||||
fixedCacheKey
|
||||
} = {}) => {
|
||||
const {
|
||||
select,
|
||||
initiate
|
||||
} = api.endpoints[name];
|
||||
const dispatch = useDispatch();
|
||||
const [promise, setPromise] = (0, import_react.useState)();
|
||||
(0, import_react.useEffect)(() => () => {
|
||||
if (!promise?.arg.fixedCacheKey) {
|
||||
promise?.reset();
|
||||
}
|
||||
}, [promise]);
|
||||
const triggerMutation = (0, import_react.useCallback)(function(arg) {
|
||||
const promise2 = dispatch(initiate(arg, {
|
||||
fixedCacheKey
|
||||
}));
|
||||
setPromise(promise2);
|
||||
return promise2;
|
||||
}, [dispatch, initiate, fixedCacheKey]);
|
||||
const {
|
||||
requestId
|
||||
} = promise || {};
|
||||
const selectDefaultResult = (0, import_react.useMemo)(() => select({
|
||||
fixedCacheKey,
|
||||
requestId: promise?.requestId
|
||||
}), [fixedCacheKey, promise, select]);
|
||||
const mutationSelector = (0, import_react.useMemo)(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
||||
const currentState = useSelector(mutationSelector, import_react_redux.shallowEqual);
|
||||
const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : void 0;
|
||||
const reset = (0, import_react.useCallback)(() => {
|
||||
batch(() => {
|
||||
if (promise) {
|
||||
setPromise(void 0);
|
||||
}
|
||||
if (fixedCacheKey) {
|
||||
dispatch(api.internalActions.removeMutationResult({
|
||||
requestId,
|
||||
fixedCacheKey
|
||||
}));
|
||||
}
|
||||
});
|
||||
}, [dispatch, fixedCacheKey, promise, requestId]);
|
||||
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
||||
(0, import_react.useDebugValue)(debugValue);
|
||||
const finalState = (0, import_react.useMemo)(() => ({
|
||||
...currentState,
|
||||
originalArgs,
|
||||
reset
|
||||
}), [currentState, originalArgs, reset]);
|
||||
return (0, import_react.useMemo)(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// src/query/react/module.ts
|
||||
var reactHooksModuleName = /* @__PURE__ */ Symbol();
|
||||
var reactHooksModule = ({
|
||||
batch = import_react_redux2.batch,
|
||||
hooks = {
|
||||
useDispatch: import_react_redux2.useDispatch,
|
||||
useSelector: import_react_redux2.useSelector,
|
||||
useStore: import_react_redux2.useStore
|
||||
},
|
||||
createSelector = import_reselect.createSelector,
|
||||
unstable__sideEffectsInRender = false,
|
||||
...rest
|
||||
} = {}) => {
|
||||
if (true) {
|
||||
const hookNames = ["useDispatch", "useSelector", "useStore"];
|
||||
let warned = false;
|
||||
for (const hookName of hookNames) {
|
||||
if (countObjectKeys(rest) > 0) {
|
||||
if (rest[hookName]) {
|
||||
if (!warned) {
|
||||
console.warn("As of RTK 2.0, the hooks now need to be specified as one object, provided under a `hooks` key:\n`reactHooksModule({ hooks: { useDispatch, useSelector, useStore } })`");
|
||||
warned = true;
|
||||
}
|
||||
}
|
||||
hooks[hookName] = rest[hookName];
|
||||
}
|
||||
if (typeof hooks[hookName] !== "function") {
|
||||
throw new Error(false ? _formatProdErrorMessage4(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(", ")}.
|
||||
Hook ${hookName} was either not provided or not a function.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
name: reactHooksModuleName,
|
||||
init(api, {
|
||||
serializeQueryArgs
|
||||
}, context) {
|
||||
const anyApi = api;
|
||||
const {
|
||||
buildQueryHooks,
|
||||
buildInfiniteQueryHooks,
|
||||
buildMutationHook,
|
||||
usePrefetch
|
||||
} = buildHooks({
|
||||
api,
|
||||
moduleOptions: {
|
||||
batch,
|
||||
hooks,
|
||||
unstable__sideEffectsInRender,
|
||||
createSelector
|
||||
},
|
||||
serializeQueryArgs,
|
||||
context
|
||||
});
|
||||
safeAssign(anyApi, {
|
||||
usePrefetch
|
||||
});
|
||||
safeAssign(context, {
|
||||
batch
|
||||
});
|
||||
return {
|
||||
injectEndpoint(endpointName, definition) {
|
||||
if (isQueryDefinition(definition)) {
|
||||
const {
|
||||
useQuery,
|
||||
useLazyQuery,
|
||||
useLazyQuerySubscription,
|
||||
useQueryState,
|
||||
useQuerySubscription
|
||||
} = buildQueryHooks(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useQuery,
|
||||
useLazyQuery,
|
||||
useLazyQuerySubscription,
|
||||
useQueryState,
|
||||
useQuerySubscription
|
||||
});
|
||||
api[`use${capitalize(endpointName)}Query`] = useQuery;
|
||||
api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
|
||||
}
|
||||
if (isMutationDefinition(definition)) {
|
||||
const useMutation = buildMutationHook(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useMutation
|
||||
});
|
||||
api[`use${capitalize(endpointName)}Mutation`] = useMutation;
|
||||
} else if (isInfiniteQueryDefinition(definition)) {
|
||||
const {
|
||||
useInfiniteQuery,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQueryState
|
||||
} = buildInfiniteQueryHooks(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useInfiniteQuery,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQueryState
|
||||
});
|
||||
api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// src/query/react/index.ts
|
||||
__reExport(react_exports, require("@reduxjs/toolkit/query"), module.exports);
|
||||
|
||||
// src/query/react/ApiProvider.tsx
|
||||
var import_toolkit3 = require("@reduxjs/toolkit");
|
||||
var React = __toESM(require("react"));
|
||||
function ApiProvider(props) {
|
||||
const context = props.context || import_react_redux.ReactReduxContext;
|
||||
const existingContext = (0, import_react.useContext)(context);
|
||||
if (existingContext) {
|
||||
throw new Error(false ? _formatProdErrorMessage5(35) : "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.");
|
||||
}
|
||||
const [store] = React.useState(() => (0, import_toolkit3.configureStore)({
|
||||
reducer: {
|
||||
[props.api.reducerPath]: props.api.reducer
|
||||
},
|
||||
middleware: (gDM) => gDM().concat(props.api.middleware)
|
||||
}));
|
||||
(0, import_react.useEffect)(() => props.setupListeners === false ? void 0 : (0, import_query.setupListeners)(store.dispatch, props.setupListeners), [props.setupListeners, store.dispatch]);
|
||||
return /* @__PURE__ */ React.createElement(import_react_redux.Provider, { store, context }, props.children);
|
||||
}
|
||||
|
||||
// src/query/react/index.ts
|
||||
var createApi = /* @__PURE__ */ (0, import_query.buildCreateApi)((0, import_query.coreModule)(), reactHooksModule());
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ApiProvider,
|
||||
UNINITIALIZED_VALUE,
|
||||
createApi,
|
||||
reactHooksModule,
|
||||
reactHooksModuleName,
|
||||
...require("@reduxjs/toolkit/query")
|
||||
});
|
||||
//# sourceMappingURL=rtk-query-react.development.cjs.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs
generated
vendored
Normal file
2
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
980
frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.mts
generated
vendored
Normal file
980
frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,980 @@
|
||||
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
||||
import { QueryDefinition, TSHelpersId, TSHelpersOverride, QuerySubState, ResultTypeFrom, QueryStatus, QueryArgFrom, SkipToken, SubscriptionOptions, TSHelpersNoInfer, QueryActionCreatorResult, MutationDefinition, MutationResultSelectorResult, MutationActionCreatorResult, InfiniteQueryDefinition, InfiniteQuerySubState, PageParamFrom, InfiniteQueryArgFrom, InfiniteQueryActionCreatorResult, BaseQueryFn, EndpointDefinitions, DefinitionType, QueryKeys, PrefetchOptions, Module, Api, setupListeners } from '@reduxjs/toolkit/query';
|
||||
export * from '@reduxjs/toolkit/query';
|
||||
import * as react_redux from 'react-redux';
|
||||
import { ReactReduxContextValue } from 'react-redux';
|
||||
import { CreateSelectorFunction } from 'reselect';
|
||||
import * as React from 'react';
|
||||
import { Context } from 'react';
|
||||
|
||||
type InfiniteData<DataType, PageParam> = {
|
||||
pages: Array<DataType>;
|
||||
pageParams: Array<PageParam>;
|
||||
};
|
||||
type InfiniteQueryDirection = 'forward' | 'backward';
|
||||
|
||||
export declare const UNINITIALIZED_VALUE: unique symbol;
|
||||
type UninitializedValue = typeof UNINITIALIZED_VALUE;
|
||||
|
||||
type QueryHooks<Definition extends QueryDefinition<any, any, any, any, any>> = {
|
||||
useQuery: UseQuery<Definition>;
|
||||
useLazyQuery: UseLazyQuery<Definition>;
|
||||
useQuerySubscription: UseQuerySubscription<Definition>;
|
||||
useLazyQuerySubscription: UseLazyQuerySubscription<Definition>;
|
||||
useQueryState: UseQueryState<Definition>;
|
||||
};
|
||||
type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
||||
useInfiniteQuery: UseInfiniteQuery<Definition>;
|
||||
useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;
|
||||
useInfiniteQueryState: UseInfiniteQueryState<Definition>;
|
||||
};
|
||||
type MutationHooks<Definition extends MutationDefinition<any, any, any, any, any>> = {
|
||||
useMutation: UseMutation<Definition>;
|
||||
};
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.
|
||||
*
|
||||
* This hook combines the functionality of both [`useQueryState`](#usequerystate) and [`useQuerySubscription`](#usequerysubscription) together, and is intended to be used in the majority of situations.
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions & UseQueryStateOptions<D, R>) => UseQueryHookResult<D, R>;
|
||||
type TypedUseQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseQueryHookResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & UseQuerySubscriptionResult<D>;
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQuery` hook in userland code.
|
||||
*/
|
||||
type TypedUseQueryHookResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery, R> & TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery>;
|
||||
type UseQuerySubscriptionOptions = SubscriptionOptions & {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* // codeblock-meta no-transpile title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.
|
||||
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
||||
* - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.
|
||||
* - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.
|
||||
*
|
||||
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
||||
*/
|
||||
refetchOnMountOrArgChange?: boolean | number;
|
||||
};
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.
|
||||
*
|
||||
* Note that this hook does not return a request status or cached data. For that use-case, see [`useQuery`](#usequery) or [`useQueryState`](#usequerystate).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
*/
|
||||
type UseQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions) => UseQuerySubscriptionResult<D>;
|
||||
type TypedUseQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseQuerySubscriptionResult<D extends QueryDefinition<any, any, any, any>> = Pick<QueryActionCreatorResult<D>, 'refetch'>;
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQuerySubscription` hook in userland code.
|
||||
*/
|
||||
type TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscriptionResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseLazyQueryLastPromiseInfo<D extends QueryDefinition<any, any, any, any>> = {
|
||||
lastArg: QueryArgFrom<D>;
|
||||
};
|
||||
/**
|
||||
* A React hook similar to [`useQuery`](#usequery), but with manual control over when the data fetching occurs.
|
||||
*
|
||||
* This hook includes the functionality of [`useLazyQuerySubscription`](#uselazyquerysubscription).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Manual control over firing a request to retrieve data
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once
|
||||
*
|
||||
* #### Note
|
||||
*
|
||||
* When the trigger function returned from a LazyQuery is called, it always initiates a new request to the server even if there is cached data. Set `preferCacheValue`(the second argument to the function) as `true` if you want it to immediately return a cached value if one exists.
|
||||
*/
|
||||
type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>) => [
|
||||
LazyQueryTrigger<D>,
|
||||
UseLazyQueryStateResult<D, R>,
|
||||
UseLazyQueryLastPromiseInfo<D>
|
||||
];
|
||||
type TypedUseLazyQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseLazyQueryStateResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & {
|
||||
/**
|
||||
* Resets the hook state to its initial `uninitialized` state.
|
||||
* This will also remove the last result from the cache.
|
||||
*/
|
||||
reset: () => void;
|
||||
};
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useLazyQuery` hook in userland code.
|
||||
*/
|
||||
type TypedUseLazyQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseLazyQueryStateResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
||||
type LazyQueryTrigger<D extends QueryDefinition<any, any, any, any>> = {
|
||||
/**
|
||||
* Triggers a lazy query.
|
||||
*
|
||||
* By default, this will start a new request even if there is already a value in the cache.
|
||||
* If you want to use the cache value and only start a request if there is no cache value, set the second argument to `true`.
|
||||
*
|
||||
* @remarks
|
||||
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using .unwrap with async await"
|
||||
* try {
|
||||
* const payload = await getUserById(1).unwrap();
|
||||
* console.log('fulfilled', payload)
|
||||
* } catch (error) {
|
||||
* console.error('rejected', error);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
(arg: QueryArgFrom<D>, preferCacheValue?: boolean): QueryActionCreatorResult<D>;
|
||||
};
|
||||
type TypedLazyQueryTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = LazyQueryTrigger<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook similar to [`useQuerySubscription`](#usequerysubscription), but with manual control over when the data fetching occurs.
|
||||
*
|
||||
* Note that this hook does not return a request status or cached data. For that use-case, see [`useLazyQuery`](#uselazyquery).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Manual control over firing a request to retrieve data
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once
|
||||
*/
|
||||
type UseLazyQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (options?: SubscriptionOptions) => readonly [
|
||||
LazyQueryTrigger<D>,
|
||||
QueryArgFrom<D> | UninitializedValue,
|
||||
{
|
||||
reset: () => void;
|
||||
}
|
||||
];
|
||||
type TypedUseLazyQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type QueryStateSelector<R extends Record<string, any>, D extends QueryDefinition<any, any, any, any>> = (state: UseQueryStateDefaultResult<D>) => R;
|
||||
/**
|
||||
* Provides a way to define a strongly-typed version of
|
||||
* {@linkcode QueryStateSelector} for use with a specific query.
|
||||
* This is useful for scenarios where you want to create a "pre-typed"
|
||||
* {@linkcode UseQueryStateOptions.selectFromResult | selectFromResult}
|
||||
* function.
|
||||
*
|
||||
* @example
|
||||
* <caption>#### __Create a strongly-typed `selectFromResult` selector function__</caption>
|
||||
*
|
||||
* ```tsx
|
||||
* import type { TypedQueryStateSelector } from '@reduxjs/toolkit/query/react'
|
||||
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
||||
*
|
||||
* type Post = {
|
||||
* id: number
|
||||
* title: string
|
||||
* }
|
||||
*
|
||||
* type PostsApiResponse = {
|
||||
* posts: Post[]
|
||||
* total: number
|
||||
* skip: number
|
||||
* limit: number
|
||||
* }
|
||||
*
|
||||
* type QueryArgument = number | undefined
|
||||
*
|
||||
* type BaseQueryFunction = ReturnType<typeof fetchBaseQuery>
|
||||
*
|
||||
* type SelectedResult = Pick<PostsApiResponse, 'posts'>
|
||||
*
|
||||
* const postsApiSlice = createApi({
|
||||
* baseQuery: fetchBaseQuery({ baseUrl: 'https://dummyjson.com/posts' }),
|
||||
* reducerPath: 'postsApi',
|
||||
* tagTypes: ['Posts'],
|
||||
* endpoints: (build) => ({
|
||||
* getPosts: build.query<PostsApiResponse, QueryArgument>({
|
||||
* query: (limit = 5) => `?limit=${limit}&select=title`,
|
||||
* }),
|
||||
* }),
|
||||
* })
|
||||
*
|
||||
* const { useGetPostsQuery } = postsApiSlice
|
||||
*
|
||||
* function PostById({ id }: { id: number }) {
|
||||
* const { post } = useGetPostsQuery(undefined, {
|
||||
* selectFromResult: (state) => ({
|
||||
* post: state.data?.posts.find((post) => post.id === id),
|
||||
* }),
|
||||
* })
|
||||
*
|
||||
* return <li>{post?.title}</li>
|
||||
* }
|
||||
*
|
||||
* const EMPTY_ARRAY: Post[] = []
|
||||
*
|
||||
* const typedSelectFromResult: TypedQueryStateSelector<
|
||||
* PostsApiResponse,
|
||||
* QueryArgument,
|
||||
* BaseQueryFunction,
|
||||
* SelectedResult
|
||||
* > = (state) => ({ posts: state.data?.posts ?? EMPTY_ARRAY })
|
||||
*
|
||||
* function PostsList() {
|
||||
* const { posts } = useGetPostsQuery(undefined, {
|
||||
* selectFromResult: typedSelectFromResult,
|
||||
* })
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* <ul>
|
||||
* {posts.map((post) => (
|
||||
* <PostById key={post.id} id={post.id} />
|
||||
* ))}
|
||||
* </ul>
|
||||
* </div>
|
||||
* )
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @template ResultType - The type of the result `data` returned by the query.
|
||||
* @template QueryArgumentType - The type of the argument passed into the query.
|
||||
* @template BaseQueryFunctionType - The type of the base query function being used.
|
||||
* @template SelectedResultType - The type of the selected result returned by the __`selectFromResult`__ function.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @public
|
||||
*/
|
||||
type TypedQueryStateSelector<ResultType, QueryArgumentType, BaseQueryFunctionType extends BaseQueryFn, SelectedResultType extends Record<string, any> = UseQueryStateDefaultResult<QueryDefinition<QueryArgumentType, BaseQueryFunctionType, string, ResultType, string>>> = QueryStateSelector<SelectedResultType, QueryDefinition<QueryArgumentType, BaseQueryFunctionType, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
|
||||
*
|
||||
* Note that this hook does not trigger fetching new data. For that use-case, see [`useQuery`](#usequery) or [`useQuerySubscription`](#usequerysubscription).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseQueryState<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(arg: QueryArgFrom<D> | SkipToken, options?: UseQueryStateOptions<D, R>) => UseQueryStateResult<D, R>;
|
||||
type TypedUseQueryState<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQueryState<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type UseQueryStateOptions<D extends QueryDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When skip is true:
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
||||
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
||||
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
||||
* function PostsList() {
|
||||
* const { data: posts } = api.useGetPostsQuery();
|
||||
*
|
||||
* return (
|
||||
* <ul>
|
||||
* {posts?.data?.map((post) => (
|
||||
* <PostById key={post.id} id={post.id} />
|
||||
* ))}
|
||||
* </ul>
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* function PostById({ id }: { id: number }) {
|
||||
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
||||
* const { post } = api.useGetPostsQuery(undefined, {
|
||||
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
||||
* });
|
||||
*
|
||||
* return <li>{post?.name}</li>;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
selectFromResult?: QueryStateSelector<R, D>;
|
||||
};
|
||||
/**
|
||||
* Provides a way to define a "pre-typed" version of
|
||||
* {@linkcode UseQueryStateOptions} with specific options for a given query.
|
||||
* This is particularly useful for setting default query behaviors such as
|
||||
* refetching strategies, which can be overridden as needed.
|
||||
*
|
||||
* @example
|
||||
* <caption>#### __Create a `useQuery` hook with default options__</caption>
|
||||
*
|
||||
* ```ts
|
||||
* import type {
|
||||
* SubscriptionOptions,
|
||||
* TypedUseQueryStateOptions,
|
||||
* } from '@reduxjs/toolkit/query/react'
|
||||
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
||||
*
|
||||
* type Post = {
|
||||
* id: number
|
||||
* name: string
|
||||
* }
|
||||
*
|
||||
* const api = createApi({
|
||||
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
|
||||
* tagTypes: ['Post'],
|
||||
* endpoints: (build) => ({
|
||||
* getPosts: build.query<Post[], void>({
|
||||
* query: () => 'posts',
|
||||
* }),
|
||||
* }),
|
||||
* })
|
||||
*
|
||||
* const { useGetPostsQuery } = api
|
||||
*
|
||||
* export const useGetPostsQueryWithDefaults = <
|
||||
* SelectedResult extends Record<string, any>,
|
||||
* >(
|
||||
* overrideOptions: TypedUseQueryStateOptions<
|
||||
* Post[],
|
||||
* void,
|
||||
* ReturnType<typeof fetchBaseQuery>,
|
||||
* SelectedResult
|
||||
* > &
|
||||
* SubscriptionOptions,
|
||||
* ) =>
|
||||
* useGetPostsQuery(undefined, {
|
||||
* // Insert default options here
|
||||
*
|
||||
* refetchOnMountOrArgChange: true,
|
||||
* refetchOnFocus: true,
|
||||
* ...overrideOptions,
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @template ResultType - The type of the result `data` returned by the query.
|
||||
* @template QueryArg - The type of the argument passed into the query.
|
||||
* @template BaseQuery - The type of the base query function being used.
|
||||
* @template SelectedResult - The type of the selected result returned by the __`selectFromResult`__ function.
|
||||
*
|
||||
* @since 2.2.8
|
||||
* @public
|
||||
*/
|
||||
type TypedUseQueryStateOptions<ResultType, QueryArg, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseQueryStateOptions<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, SelectedResult>;
|
||||
type UseQueryStateResult<_ extends QueryDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R>;
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQueryState` hook in userland code.
|
||||
*/
|
||||
type TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TSHelpersNoInfer<R>;
|
||||
type UseQueryStateBaseResult<D extends QueryDefinition<any, any, any, any>> = QuerySubState<D> & {
|
||||
/**
|
||||
* Where `data` tries to hold data as much as possible, also re-using
|
||||
* data from the last arguments passed into the hook, this property
|
||||
* will always contain the received data from the query, for the current query arguments.
|
||||
*/
|
||||
currentData?: ResultTypeFrom<D>;
|
||||
/**
|
||||
* Query has not started yet.
|
||||
*/
|
||||
isUninitialized: false;
|
||||
/**
|
||||
* Query is currently loading for the first time. No data yet.
|
||||
*/
|
||||
isLoading: false;
|
||||
/**
|
||||
* Query is currently fetching, but might have data from an earlier request.
|
||||
*/
|
||||
isFetching: false;
|
||||
/**
|
||||
* Query has data from a successful load.
|
||||
*/
|
||||
isSuccess: false;
|
||||
/**
|
||||
* Query is currently in "error" state.
|
||||
*/
|
||||
isError: false;
|
||||
};
|
||||
type UseQueryStateUninitialized<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<Extract<UseQueryStateBaseResult<D>, {
|
||||
status: QueryStatus.uninitialized;
|
||||
}>, {
|
||||
isUninitialized: true;
|
||||
}>;
|
||||
type UseQueryStateLoading<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isLoading: true;
|
||||
isFetching: boolean;
|
||||
data: undefined;
|
||||
}>;
|
||||
type UseQueryStateSuccessFetching<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isSuccess: true;
|
||||
isFetching: true;
|
||||
error: undefined;
|
||||
} & {
|
||||
data: ResultTypeFrom<D>;
|
||||
} & Required<Pick<UseQueryStateBaseResult<D>, 'fulfilledTimeStamp'>>>;
|
||||
type UseQueryStateSuccessNotFetching<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isSuccess: true;
|
||||
isFetching: false;
|
||||
error: undefined;
|
||||
} & {
|
||||
data: ResultTypeFrom<D>;
|
||||
currentData: ResultTypeFrom<D>;
|
||||
} & Required<Pick<UseQueryStateBaseResult<D>, 'fulfilledTimeStamp'>>>;
|
||||
type UseQueryStateError<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isError: true;
|
||||
} & Required<Pick<UseQueryStateBaseResult<D>, 'error'>>>;
|
||||
type UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> = TSHelpersId<UseQueryStateUninitialized<D> | UseQueryStateLoading<D> | UseQueryStateSuccessFetching<D> | UseQueryStateSuccessNotFetching<D> | UseQueryStateError<D>> & {
|
||||
/**
|
||||
* @deprecated Included for completeness, but discouraged.
|
||||
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
||||
* and `isUninitialized` flags instead
|
||||
*/
|
||||
status: QueryStatus;
|
||||
};
|
||||
type LazyInfiniteQueryTrigger<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
||||
/**
|
||||
* Triggers a lazy query.
|
||||
*
|
||||
* By default, this will start a new request even if there is already a value in the cache.
|
||||
* If you want to use the cache value and only start a request if there is no cache value, set the second argument to `true`.
|
||||
*
|
||||
* @remarks
|
||||
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using .unwrap with async await"
|
||||
* try {
|
||||
* const payload = await getUserById(1).unwrap();
|
||||
* console.log('fulfilled', payload)
|
||||
* } catch (error) {
|
||||
* console.error('rejected', error);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
(arg: QueryArgFrom<D>, direction: InfiniteQueryDirection): InfiniteQueryActionCreatorResult<D>;
|
||||
};
|
||||
type TypedLazyInfiniteQueryTrigger<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = LazyInfiniteQueryTrigger<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
type UseInfiniteQuerySubscriptionOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>> = SubscriptionOptions & {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* // codeblock-meta no-transpile title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.
|
||||
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
||||
* - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.
|
||||
* - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.
|
||||
*
|
||||
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
||||
*/
|
||||
refetchOnMountOrArgChange?: boolean | number;
|
||||
initialPageParam?: PageParamFrom<D>;
|
||||
/**
|
||||
* Defaults to `true`. When this is `true` and an infinite query endpoint is refetched
|
||||
* (due to tag invalidation, polling, arg change configuration, or manual refetching),
|
||||
* RTK Query will try to sequentially refetch all pages currently in the cache.
|
||||
* When `false` only the first page will be refetched.
|
||||
*
|
||||
* This option applies to all automatic refetches for this subscription (polling, tag invalidation, etc.).
|
||||
* It can be overridden on a per-call basis using the `refetch()` method.
|
||||
*/
|
||||
refetchCachedPages?: boolean;
|
||||
};
|
||||
type TypedUseInfiniteQuerySubscription<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscription<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
type UseInfiniteQuerySubscriptionResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
||||
refetch: (options?: Pick<UseInfiniteQuerySubscriptionOptions<D>, 'refetchCachedPages'>) => InfiniteQueryActionCreatorResult<D>;
|
||||
trigger: LazyInfiniteQueryTrigger<D>;
|
||||
fetchNextPage: () => InfiniteQueryActionCreatorResult<D>;
|
||||
fetchPreviousPage: () => InfiniteQueryActionCreatorResult<D>;
|
||||
};
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQuerySubscription` hook in userland code.
|
||||
*/
|
||||
type TypedUseInfiniteQuerySubscriptionResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscriptionResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
type InfiniteQueryStateSelector<R extends Record<string, any>, D extends InfiniteQueryDefinition<any, any, any, any, any>> = (state: UseInfiniteQueryStateDefaultResult<D>) => R;
|
||||
type TypedInfiniteQueryStateSelector<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = InfiniteQueryStateSelector<SelectedResult, InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available. Additionally, it will cache multiple "pages" worth of responses within a single cache entry, and allows fetching more pages forwards and backwards from the current cached pages.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.
|
||||
*
|
||||
* The `data` field will be a `{pages: Data[], pageParams: PageParam[]}` structure containing all fetched page responses and the corresponding page param values for each page. You may use this to render individual pages, combine all pages into a single infinite list, or other display logic as needed.
|
||||
*
|
||||
* This hook combines the functionality of both [`useInfiniteQueryState`](#useinfinitequerystate) and [`useInfiniteQuerySubscription`](#useinfinitequerysubscription) together, and is intended to be used in the majority of situations.
|
||||
*
|
||||
* As with normal query hooks, `skipToken` is a valid argument that will skip the query from executing.
|
||||
*
|
||||
* By default, the initial request will use the `initialPageParam` value that was defined on the infinite query endpoint. If you want to start from a different value, you can pass `initialPageParam` as part of the hook options to override that initial request value.
|
||||
*
|
||||
* Use the returned `fetchNextPage` and `fetchPreviousPage` methods on the hook result object to trigger fetches forwards and backwards. These will always calculate the next or previous page param based on the current cached pages and the provided `getNext/PreviousPageParam` callbacks defined in the endpoint.
|
||||
*
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseInfiniteQuery<D extends InfiniteQueryDefinition<any, any, any, any, any>> = <R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<D>>(arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D> & UseInfiniteQueryStateOptions<D, R>) => UseInfiniteQueryHookResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'fetchNextPage' | 'fetchPreviousPage'>;
|
||||
type TypedUseInfiniteQuery<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuery<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
|
||||
*
|
||||
* Note that this hook does not trigger fetching new data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQuerySubscription`](#useinfinitequerysubscription).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseInfiniteQueryState<D extends InfiniteQueryDefinition<any, any, any, any, any>> = <R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<D>>(arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQueryStateOptions<D, R>) => UseInfiniteQueryStateResult<D, R>;
|
||||
type TypedUseInfiniteQueryState<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQueryState<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data. Additionally, it will cache multiple "pages" worth of responses within a single cache entry, and allows fetching more pages forwards and backwards from the current cached pages.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.
|
||||
*
|
||||
* Note that this hook does not return a request status or cached data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQueryState`](#useinfinitequerystate).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
*/
|
||||
type UseInfiniteQuerySubscription<D extends InfiniteQueryDefinition<any, any, any, any, any>> = (arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D>) => UseInfiniteQuerySubscriptionResult<D>;
|
||||
type UseInfiniteQueryHookResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = UseInfiniteQueryStateResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'refetch' | 'fetchNextPage' | 'fetchPreviousPage'>;
|
||||
type TypedUseInfiniteQueryHookResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryHookResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, R>;
|
||||
type UseInfiniteQueryStateOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>, R extends Record<string, any>> = {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When skip is true:
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
||||
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
||||
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
||||
* Note that this should always return an object (not a primitive), as RTKQ adds fields to the return value.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
||||
* function PostsList() {
|
||||
* const { data: posts } = api.useGetPostsQuery();
|
||||
*
|
||||
* return (
|
||||
* <ul>
|
||||
* {posts?.data?.map((post) => (
|
||||
* <PostById key={post.id} id={post.id} />
|
||||
* ))}
|
||||
* </ul>
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* function PostById({ id }: { id: number }) {
|
||||
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
||||
* const { post } = api.useGetPostsQuery(undefined, {
|
||||
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
||||
* });
|
||||
*
|
||||
* return <li>{post?.name}</li>;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
selectFromResult?: InfiniteQueryStateSelector<R, D>;
|
||||
};
|
||||
type TypedUseInfiniteQueryStateOptions<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryStateOptions<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, SelectedResult>;
|
||||
type UseInfiniteQueryStateResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = TSHelpersNoInfer<R>;
|
||||
type TypedUseInfiniteQueryStateResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, R = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryStateResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, R>;
|
||||
type UseInfiniteQueryStateBaseResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = InfiniteQuerySubState<D> & {
|
||||
/**
|
||||
* Where `data` tries to hold data as much as possible, also re-using
|
||||
* data from the last arguments passed into the hook, this property
|
||||
* will always contain the received data from the query, for the current query arguments.
|
||||
*/
|
||||
currentData?: InfiniteData<ResultTypeFrom<D>, PageParamFrom<D>>;
|
||||
/**
|
||||
* Query has not started yet.
|
||||
*/
|
||||
isUninitialized: false;
|
||||
/**
|
||||
* Query is currently loading for the first time. No data yet.
|
||||
*/
|
||||
isLoading: false;
|
||||
/**
|
||||
* Query is currently fetching, but might have data from an earlier request.
|
||||
*/
|
||||
isFetching: false;
|
||||
/**
|
||||
* Query has data from a successful load.
|
||||
*/
|
||||
isSuccess: false;
|
||||
/**
|
||||
* Query is currently in "error" state.
|
||||
*/
|
||||
isError: false;
|
||||
hasNextPage: boolean;
|
||||
hasPreviousPage: boolean;
|
||||
isFetchingNextPage: boolean;
|
||||
isFetchingPreviousPage: boolean;
|
||||
};
|
||||
type UseInfiniteQueryStateDefaultResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseInfiniteQueryStateBaseResult<D>, {
|
||||
status: QueryStatus.uninitialized;
|
||||
}>, {
|
||||
isUninitialized: true;
|
||||
}> | TSHelpersOverride<UseInfiniteQueryStateBaseResult<D>, {
|
||||
isLoading: true;
|
||||
isFetching: boolean;
|
||||
data: undefined;
|
||||
} | ({
|
||||
isSuccess: true;
|
||||
isFetching: true;
|
||||
error: undefined;
|
||||
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
|
||||
isSuccess: true;
|
||||
isFetching: false;
|
||||
error: undefined;
|
||||
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
|
||||
isError: true;
|
||||
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'error'>>)>> & {
|
||||
/**
|
||||
* @deprecated Included for completeness, but discouraged.
|
||||
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
||||
* and `isUninitialized` flags instead
|
||||
*/
|
||||
status: QueryStatus;
|
||||
};
|
||||
type MutationStateSelector<R extends Record<string, any>, D extends MutationDefinition<any, any, any, any>> = (state: MutationResultSelectorResult<D>) => R;
|
||||
type UseMutationStateOptions<D extends MutationDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
||||
selectFromResult?: MutationStateSelector<R, D>;
|
||||
fixedCacheKey?: string;
|
||||
};
|
||||
type UseMutationStateResult<D extends MutationDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R> & {
|
||||
originalArgs?: QueryArgFrom<D>;
|
||||
/**
|
||||
* Resets the hook state to its initial `uninitialized` state.
|
||||
* This will also remove the last result from the cache.
|
||||
*/
|
||||
reset: () => void;
|
||||
};
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useMutation` hook in userland code.
|
||||
*/
|
||||
type TypedUseMutationResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = MutationResultSelectorResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseMutationStateResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
||||
/**
|
||||
* A React hook that lets you trigger an update request for a given endpoint, and subscribes the component to read the request status from the Redux store. The component will re-render as the loading status changes.
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Manual control over firing a request to alter data on the server or possibly invalidate the cache
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseMutation<D extends MutationDefinition<any, any, any, any>> = <R extends Record<string, any> = MutationResultSelectorResult<D>>(options?: UseMutationStateOptions<D, R>) => readonly [MutationTrigger<D>, UseMutationStateResult<D, R>];
|
||||
type TypedUseMutation<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseMutation<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type MutationTrigger<D extends MutationDefinition<any, any, any, any>> = {
|
||||
/**
|
||||
* Triggers the mutation and returns a Promise.
|
||||
* @remarks
|
||||
* If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using .unwrap with async await"
|
||||
* try {
|
||||
* const payload = await addPost({ id: 1, name: 'Example' }).unwrap();
|
||||
* console.log('fulfilled', payload)
|
||||
* } catch (error) {
|
||||
* console.error('rejected', error);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
(arg: QueryArgFrom<D>): MutationActionCreatorResult<D>;
|
||||
};
|
||||
type TypedMutationTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = MutationTrigger<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
|
||||
type QueryHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.query;
|
||||
} ? `use${Capitalize<K & string>}Query` : never]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
||||
};
|
||||
type LazyQueryHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.query;
|
||||
} ? `useLazy${Capitalize<K & string>}Query` : never]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
||||
};
|
||||
type InfiniteQueryHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.infinitequery;
|
||||
} ? `use${Capitalize<K & string>}InfiniteQuery` : never]: UseInfiniteQuery<Extract<Definitions[K], InfiniteQueryDefinition<any, any, any, any, any>>>;
|
||||
};
|
||||
type MutationHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.mutation;
|
||||
} ? `use${Capitalize<K & string>}Mutation` : never]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
|
||||
};
|
||||
type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = QueryHookNames<Definitions> & LazyQueryHookNames<Definitions> & InfiniteQueryHookNames<Definitions> & MutationHookNames<Definitions>;
|
||||
|
||||
export declare const reactHooksModuleName: unique symbol;
|
||||
type ReactHooksModule = typeof reactHooksModuleName;
|
||||
declare module '@reduxjs/toolkit/query' {
|
||||
interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
|
||||
[reactHooksModuleName]: {
|
||||
/**
|
||||
* Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.
|
||||
*/
|
||||
endpoints: {
|
||||
[K in keyof Definitions]: Definitions[K] extends QueryDefinition<any, any, any, any, any> ? QueryHooks<Definitions[K]> : Definitions[K] extends MutationDefinition<any, any, any, any, any> ? MutationHooks<Definitions[K]> : Definitions[K] extends InfiniteQueryDefinition<any, any, any, any, any> ? InfiniteQueryHooks<Definitions[K]> : never;
|
||||
};
|
||||
/**
|
||||
* A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.
|
||||
*/
|
||||
usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
|
||||
} & HooksWithUniqueNames<Definitions>;
|
||||
}
|
||||
}
|
||||
type RR = typeof react_redux;
|
||||
interface ReactHooksModuleOptions {
|
||||
/**
|
||||
* The hooks from React Redux to be used
|
||||
*/
|
||||
hooks?: {
|
||||
/**
|
||||
* The version of the `useDispatch` hook to be used
|
||||
*/
|
||||
useDispatch: RR['useDispatch'];
|
||||
/**
|
||||
* The version of the `useSelector` hook to be used
|
||||
*/
|
||||
useSelector: RR['useSelector'];
|
||||
/**
|
||||
* The version of the `useStore` hook to be used
|
||||
*/
|
||||
useStore: RR['useStore'];
|
||||
};
|
||||
/**
|
||||
* The version of the `batchedUpdates` function to be used
|
||||
*/
|
||||
batch?: RR['batch'];
|
||||
/**
|
||||
* Enables performing asynchronous tasks immediately within a render.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import {
|
||||
* buildCreateApi,
|
||||
* coreModule,
|
||||
* reactHooksModule
|
||||
* } from '@reduxjs/toolkit/query/react'
|
||||
*
|
||||
* const createApi = buildCreateApi(
|
||||
* coreModule(),
|
||||
* reactHooksModule({ unstable__sideEffectsInRender: true })
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
unstable__sideEffectsInRender?: boolean;
|
||||
/**
|
||||
* A selector creator (usually from `reselect`, or matching the same signature)
|
||||
*/
|
||||
createSelector?: CreateSelectorFunction<any, any, any>;
|
||||
}
|
||||
/**
|
||||
* Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const MyContext = React.createContext<ReactReduxContextValue | null>(null);
|
||||
* const customCreateApi = buildCreateApi(
|
||||
* coreModule(),
|
||||
* reactHooksModule({
|
||||
* hooks: {
|
||||
* useDispatch: createDispatchHook(MyContext),
|
||||
* useSelector: createSelectorHook(MyContext),
|
||||
* useStore: createStoreHook(MyContext)
|
||||
* }
|
||||
* })
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @returns A module for use with `buildCreateApi`
|
||||
*/
|
||||
declare const reactHooksModule: ({ batch, hooks, createSelector, unstable__sideEffectsInRender, ...rest }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
|
||||
|
||||
/**
|
||||
* Can be used as a `Provider` if you **do not already have a Redux store**.
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* // codeblock-meta no-transpile title="Basic usage - wrap your App with ApiProvider"
|
||||
* import * as React from 'react';
|
||||
* import { ApiProvider } from '@reduxjs/toolkit/query/react';
|
||||
* import { Pokemon } from './features/Pokemon';
|
||||
*
|
||||
* function App() {
|
||||
* return (
|
||||
* <ApiProvider api={api}>
|
||||
* <Pokemon />
|
||||
* </ApiProvider>
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* Using this together with an existing redux store, both will
|
||||
* conflict with each other - please use the traditional redux setup
|
||||
* in that case.
|
||||
*/
|
||||
declare function ApiProvider(props: {
|
||||
children: any;
|
||||
api: Api<any, {}, any, any>;
|
||||
setupListeners?: Parameters<typeof setupListeners>[1] | false;
|
||||
context?: Context<ReactReduxContextValue | null>;
|
||||
}): React.JSX.Element;
|
||||
|
||||
declare const createApi: _reduxjs_toolkit_query.CreateApi<typeof _reduxjs_toolkit_query.coreModuleName | typeof reactHooksModuleName>;
|
||||
|
||||
export { ApiProvider, type TypedInfiniteQueryStateSelector, type TypedLazyInfiniteQueryTrigger, type TypedLazyQueryTrigger, type TypedMutationTrigger, type TypedQueryStateSelector, type TypedUseInfiniteQuery, type TypedUseInfiniteQueryHookResult, type TypedUseInfiniteQueryState, type TypedUseInfiniteQueryStateOptions, type TypedUseInfiniteQueryStateResult, type TypedUseInfiniteQuerySubscription, type TypedUseInfiniteQuerySubscriptionResult, type TypedUseLazyQuery, type TypedUseLazyQueryStateResult, type TypedUseLazyQuerySubscription, type TypedUseMutation, type TypedUseMutationResult, type TypedUseQuery, type TypedUseQueryHookResult, type TypedUseQueryState, type TypedUseQueryStateOptions, type TypedUseQueryStateResult, type TypedUseQuerySubscription, type TypedUseQuerySubscriptionResult, createApi, reactHooksModule };
|
||||
980
frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts
generated
vendored
Normal file
980
frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,980 @@
|
||||
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
||||
import { QueryDefinition, TSHelpersId, TSHelpersOverride, QuerySubState, ResultTypeFrom, QueryStatus, QueryArgFrom, SkipToken, SubscriptionOptions, TSHelpersNoInfer, QueryActionCreatorResult, MutationDefinition, MutationResultSelectorResult, MutationActionCreatorResult, InfiniteQueryDefinition, InfiniteQuerySubState, PageParamFrom, InfiniteQueryArgFrom, InfiniteQueryActionCreatorResult, BaseQueryFn, EndpointDefinitions, DefinitionType, QueryKeys, PrefetchOptions, Module, Api, setupListeners } from '@reduxjs/toolkit/query';
|
||||
export * from '@reduxjs/toolkit/query';
|
||||
import * as react_redux from 'react-redux';
|
||||
import { ReactReduxContextValue } from 'react-redux';
|
||||
import { CreateSelectorFunction } from 'reselect';
|
||||
import * as React from 'react';
|
||||
import { Context } from 'react';
|
||||
|
||||
type InfiniteData<DataType, PageParam> = {
|
||||
pages: Array<DataType>;
|
||||
pageParams: Array<PageParam>;
|
||||
};
|
||||
type InfiniteQueryDirection = 'forward' | 'backward';
|
||||
|
||||
export declare const UNINITIALIZED_VALUE: unique symbol;
|
||||
type UninitializedValue = typeof UNINITIALIZED_VALUE;
|
||||
|
||||
type QueryHooks<Definition extends QueryDefinition<any, any, any, any, any>> = {
|
||||
useQuery: UseQuery<Definition>;
|
||||
useLazyQuery: UseLazyQuery<Definition>;
|
||||
useQuerySubscription: UseQuerySubscription<Definition>;
|
||||
useLazyQuerySubscription: UseLazyQuerySubscription<Definition>;
|
||||
useQueryState: UseQueryState<Definition>;
|
||||
};
|
||||
type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
||||
useInfiniteQuery: UseInfiniteQuery<Definition>;
|
||||
useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;
|
||||
useInfiniteQueryState: UseInfiniteQueryState<Definition>;
|
||||
};
|
||||
type MutationHooks<Definition extends MutationDefinition<any, any, any, any, any>> = {
|
||||
useMutation: UseMutation<Definition>;
|
||||
};
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.
|
||||
*
|
||||
* This hook combines the functionality of both [`useQueryState`](#usequerystate) and [`useQuerySubscription`](#usequerysubscription) together, and is intended to be used in the majority of situations.
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions & UseQueryStateOptions<D, R>) => UseQueryHookResult<D, R>;
|
||||
type TypedUseQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseQueryHookResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & UseQuerySubscriptionResult<D>;
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQuery` hook in userland code.
|
||||
*/
|
||||
type TypedUseQueryHookResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery, R> & TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery>;
|
||||
type UseQuerySubscriptionOptions = SubscriptionOptions & {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* // codeblock-meta no-transpile title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.
|
||||
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
||||
* - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.
|
||||
* - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.
|
||||
*
|
||||
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
||||
*/
|
||||
refetchOnMountOrArgChange?: boolean | number;
|
||||
};
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.
|
||||
*
|
||||
* Note that this hook does not return a request status or cached data. For that use-case, see [`useQuery`](#usequery) or [`useQueryState`](#usequerystate).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
*/
|
||||
type UseQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions) => UseQuerySubscriptionResult<D>;
|
||||
type TypedUseQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseQuerySubscriptionResult<D extends QueryDefinition<any, any, any, any>> = Pick<QueryActionCreatorResult<D>, 'refetch'>;
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQuerySubscription` hook in userland code.
|
||||
*/
|
||||
type TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscriptionResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseLazyQueryLastPromiseInfo<D extends QueryDefinition<any, any, any, any>> = {
|
||||
lastArg: QueryArgFrom<D>;
|
||||
};
|
||||
/**
|
||||
* A React hook similar to [`useQuery`](#usequery), but with manual control over when the data fetching occurs.
|
||||
*
|
||||
* This hook includes the functionality of [`useLazyQuerySubscription`](#uselazyquerysubscription).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Manual control over firing a request to retrieve data
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once
|
||||
*
|
||||
* #### Note
|
||||
*
|
||||
* When the trigger function returned from a LazyQuery is called, it always initiates a new request to the server even if there is cached data. Set `preferCacheValue`(the second argument to the function) as `true` if you want it to immediately return a cached value if one exists.
|
||||
*/
|
||||
type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>) => [
|
||||
LazyQueryTrigger<D>,
|
||||
UseLazyQueryStateResult<D, R>,
|
||||
UseLazyQueryLastPromiseInfo<D>
|
||||
];
|
||||
type TypedUseLazyQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type UseLazyQueryStateResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & {
|
||||
/**
|
||||
* Resets the hook state to its initial `uninitialized` state.
|
||||
* This will also remove the last result from the cache.
|
||||
*/
|
||||
reset: () => void;
|
||||
};
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useLazyQuery` hook in userland code.
|
||||
*/
|
||||
type TypedUseLazyQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseLazyQueryStateResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
||||
type LazyQueryTrigger<D extends QueryDefinition<any, any, any, any>> = {
|
||||
/**
|
||||
* Triggers a lazy query.
|
||||
*
|
||||
* By default, this will start a new request even if there is already a value in the cache.
|
||||
* If you want to use the cache value and only start a request if there is no cache value, set the second argument to `true`.
|
||||
*
|
||||
* @remarks
|
||||
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using .unwrap with async await"
|
||||
* try {
|
||||
* const payload = await getUserById(1).unwrap();
|
||||
* console.log('fulfilled', payload)
|
||||
* } catch (error) {
|
||||
* console.error('rejected', error);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
(arg: QueryArgFrom<D>, preferCacheValue?: boolean): QueryActionCreatorResult<D>;
|
||||
};
|
||||
type TypedLazyQueryTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = LazyQueryTrigger<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook similar to [`useQuerySubscription`](#usequerysubscription), but with manual control over when the data fetching occurs.
|
||||
*
|
||||
* Note that this hook does not return a request status or cached data. For that use-case, see [`useLazyQuery`](#uselazyquery).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Manual control over firing a request to retrieve data
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once
|
||||
*/
|
||||
type UseLazyQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (options?: SubscriptionOptions) => readonly [
|
||||
LazyQueryTrigger<D>,
|
||||
QueryArgFrom<D> | UninitializedValue,
|
||||
{
|
||||
reset: () => void;
|
||||
}
|
||||
];
|
||||
type TypedUseLazyQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type QueryStateSelector<R extends Record<string, any>, D extends QueryDefinition<any, any, any, any>> = (state: UseQueryStateDefaultResult<D>) => R;
|
||||
/**
|
||||
* Provides a way to define a strongly-typed version of
|
||||
* {@linkcode QueryStateSelector} for use with a specific query.
|
||||
* This is useful for scenarios where you want to create a "pre-typed"
|
||||
* {@linkcode UseQueryStateOptions.selectFromResult | selectFromResult}
|
||||
* function.
|
||||
*
|
||||
* @example
|
||||
* <caption>#### __Create a strongly-typed `selectFromResult` selector function__</caption>
|
||||
*
|
||||
* ```tsx
|
||||
* import type { TypedQueryStateSelector } from '@reduxjs/toolkit/query/react'
|
||||
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
||||
*
|
||||
* type Post = {
|
||||
* id: number
|
||||
* title: string
|
||||
* }
|
||||
*
|
||||
* type PostsApiResponse = {
|
||||
* posts: Post[]
|
||||
* total: number
|
||||
* skip: number
|
||||
* limit: number
|
||||
* }
|
||||
*
|
||||
* type QueryArgument = number | undefined
|
||||
*
|
||||
* type BaseQueryFunction = ReturnType<typeof fetchBaseQuery>
|
||||
*
|
||||
* type SelectedResult = Pick<PostsApiResponse, 'posts'>
|
||||
*
|
||||
* const postsApiSlice = createApi({
|
||||
* baseQuery: fetchBaseQuery({ baseUrl: 'https://dummyjson.com/posts' }),
|
||||
* reducerPath: 'postsApi',
|
||||
* tagTypes: ['Posts'],
|
||||
* endpoints: (build) => ({
|
||||
* getPosts: build.query<PostsApiResponse, QueryArgument>({
|
||||
* query: (limit = 5) => `?limit=${limit}&select=title`,
|
||||
* }),
|
||||
* }),
|
||||
* })
|
||||
*
|
||||
* const { useGetPostsQuery } = postsApiSlice
|
||||
*
|
||||
* function PostById({ id }: { id: number }) {
|
||||
* const { post } = useGetPostsQuery(undefined, {
|
||||
* selectFromResult: (state) => ({
|
||||
* post: state.data?.posts.find((post) => post.id === id),
|
||||
* }),
|
||||
* })
|
||||
*
|
||||
* return <li>{post?.title}</li>
|
||||
* }
|
||||
*
|
||||
* const EMPTY_ARRAY: Post[] = []
|
||||
*
|
||||
* const typedSelectFromResult: TypedQueryStateSelector<
|
||||
* PostsApiResponse,
|
||||
* QueryArgument,
|
||||
* BaseQueryFunction,
|
||||
* SelectedResult
|
||||
* > = (state) => ({ posts: state.data?.posts ?? EMPTY_ARRAY })
|
||||
*
|
||||
* function PostsList() {
|
||||
* const { posts } = useGetPostsQuery(undefined, {
|
||||
* selectFromResult: typedSelectFromResult,
|
||||
* })
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* <ul>
|
||||
* {posts.map((post) => (
|
||||
* <PostById key={post.id} id={post.id} />
|
||||
* ))}
|
||||
* </ul>
|
||||
* </div>
|
||||
* )
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @template ResultType - The type of the result `data` returned by the query.
|
||||
* @template QueryArgumentType - The type of the argument passed into the query.
|
||||
* @template BaseQueryFunctionType - The type of the base query function being used.
|
||||
* @template SelectedResultType - The type of the selected result returned by the __`selectFromResult`__ function.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @public
|
||||
*/
|
||||
type TypedQueryStateSelector<ResultType, QueryArgumentType, BaseQueryFunctionType extends BaseQueryFn, SelectedResultType extends Record<string, any> = UseQueryStateDefaultResult<QueryDefinition<QueryArgumentType, BaseQueryFunctionType, string, ResultType, string>>> = QueryStateSelector<SelectedResultType, QueryDefinition<QueryArgumentType, BaseQueryFunctionType, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
|
||||
*
|
||||
* Note that this hook does not trigger fetching new data. For that use-case, see [`useQuery`](#usequery) or [`useQuerySubscription`](#usequerysubscription).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseQueryState<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(arg: QueryArgFrom<D> | SkipToken, options?: UseQueryStateOptions<D, R>) => UseQueryStateResult<D, R>;
|
||||
type TypedUseQueryState<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQueryState<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
type UseQueryStateOptions<D extends QueryDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When skip is true:
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
||||
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
||||
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
||||
* function PostsList() {
|
||||
* const { data: posts } = api.useGetPostsQuery();
|
||||
*
|
||||
* return (
|
||||
* <ul>
|
||||
* {posts?.data?.map((post) => (
|
||||
* <PostById key={post.id} id={post.id} />
|
||||
* ))}
|
||||
* </ul>
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* function PostById({ id }: { id: number }) {
|
||||
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
||||
* const { post } = api.useGetPostsQuery(undefined, {
|
||||
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
||||
* });
|
||||
*
|
||||
* return <li>{post?.name}</li>;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
selectFromResult?: QueryStateSelector<R, D>;
|
||||
};
|
||||
/**
|
||||
* Provides a way to define a "pre-typed" version of
|
||||
* {@linkcode UseQueryStateOptions} with specific options for a given query.
|
||||
* This is particularly useful for setting default query behaviors such as
|
||||
* refetching strategies, which can be overridden as needed.
|
||||
*
|
||||
* @example
|
||||
* <caption>#### __Create a `useQuery` hook with default options__</caption>
|
||||
*
|
||||
* ```ts
|
||||
* import type {
|
||||
* SubscriptionOptions,
|
||||
* TypedUseQueryStateOptions,
|
||||
* } from '@reduxjs/toolkit/query/react'
|
||||
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
||||
*
|
||||
* type Post = {
|
||||
* id: number
|
||||
* name: string
|
||||
* }
|
||||
*
|
||||
* const api = createApi({
|
||||
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
|
||||
* tagTypes: ['Post'],
|
||||
* endpoints: (build) => ({
|
||||
* getPosts: build.query<Post[], void>({
|
||||
* query: () => 'posts',
|
||||
* }),
|
||||
* }),
|
||||
* })
|
||||
*
|
||||
* const { useGetPostsQuery } = api
|
||||
*
|
||||
* export const useGetPostsQueryWithDefaults = <
|
||||
* SelectedResult extends Record<string, any>,
|
||||
* >(
|
||||
* overrideOptions: TypedUseQueryStateOptions<
|
||||
* Post[],
|
||||
* void,
|
||||
* ReturnType<typeof fetchBaseQuery>,
|
||||
* SelectedResult
|
||||
* > &
|
||||
* SubscriptionOptions,
|
||||
* ) =>
|
||||
* useGetPostsQuery(undefined, {
|
||||
* // Insert default options here
|
||||
*
|
||||
* refetchOnMountOrArgChange: true,
|
||||
* refetchOnFocus: true,
|
||||
* ...overrideOptions,
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @template ResultType - The type of the result `data` returned by the query.
|
||||
* @template QueryArg - The type of the argument passed into the query.
|
||||
* @template BaseQuery - The type of the base query function being used.
|
||||
* @template SelectedResult - The type of the selected result returned by the __`selectFromResult`__ function.
|
||||
*
|
||||
* @since 2.2.8
|
||||
* @public
|
||||
*/
|
||||
type TypedUseQueryStateOptions<ResultType, QueryArg, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseQueryStateOptions<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, SelectedResult>;
|
||||
type UseQueryStateResult<_ extends QueryDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R>;
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQueryState` hook in userland code.
|
||||
*/
|
||||
type TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TSHelpersNoInfer<R>;
|
||||
type UseQueryStateBaseResult<D extends QueryDefinition<any, any, any, any>> = QuerySubState<D> & {
|
||||
/**
|
||||
* Where `data` tries to hold data as much as possible, also re-using
|
||||
* data from the last arguments passed into the hook, this property
|
||||
* will always contain the received data from the query, for the current query arguments.
|
||||
*/
|
||||
currentData?: ResultTypeFrom<D>;
|
||||
/**
|
||||
* Query has not started yet.
|
||||
*/
|
||||
isUninitialized: false;
|
||||
/**
|
||||
* Query is currently loading for the first time. No data yet.
|
||||
*/
|
||||
isLoading: false;
|
||||
/**
|
||||
* Query is currently fetching, but might have data from an earlier request.
|
||||
*/
|
||||
isFetching: false;
|
||||
/**
|
||||
* Query has data from a successful load.
|
||||
*/
|
||||
isSuccess: false;
|
||||
/**
|
||||
* Query is currently in "error" state.
|
||||
*/
|
||||
isError: false;
|
||||
};
|
||||
type UseQueryStateUninitialized<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<Extract<UseQueryStateBaseResult<D>, {
|
||||
status: QueryStatus.uninitialized;
|
||||
}>, {
|
||||
isUninitialized: true;
|
||||
}>;
|
||||
type UseQueryStateLoading<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isLoading: true;
|
||||
isFetching: boolean;
|
||||
data: undefined;
|
||||
}>;
|
||||
type UseQueryStateSuccessFetching<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isSuccess: true;
|
||||
isFetching: true;
|
||||
error: undefined;
|
||||
} & {
|
||||
data: ResultTypeFrom<D>;
|
||||
} & Required<Pick<UseQueryStateBaseResult<D>, 'fulfilledTimeStamp'>>>;
|
||||
type UseQueryStateSuccessNotFetching<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isSuccess: true;
|
||||
isFetching: false;
|
||||
error: undefined;
|
||||
} & {
|
||||
data: ResultTypeFrom<D>;
|
||||
currentData: ResultTypeFrom<D>;
|
||||
} & Required<Pick<UseQueryStateBaseResult<D>, 'fulfilledTimeStamp'>>>;
|
||||
type UseQueryStateError<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
||||
isError: true;
|
||||
} & Required<Pick<UseQueryStateBaseResult<D>, 'error'>>>;
|
||||
type UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> = TSHelpersId<UseQueryStateUninitialized<D> | UseQueryStateLoading<D> | UseQueryStateSuccessFetching<D> | UseQueryStateSuccessNotFetching<D> | UseQueryStateError<D>> & {
|
||||
/**
|
||||
* @deprecated Included for completeness, but discouraged.
|
||||
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
||||
* and `isUninitialized` flags instead
|
||||
*/
|
||||
status: QueryStatus;
|
||||
};
|
||||
type LazyInfiniteQueryTrigger<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
||||
/**
|
||||
* Triggers a lazy query.
|
||||
*
|
||||
* By default, this will start a new request even if there is already a value in the cache.
|
||||
* If you want to use the cache value and only start a request if there is no cache value, set the second argument to `true`.
|
||||
*
|
||||
* @remarks
|
||||
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using .unwrap with async await"
|
||||
* try {
|
||||
* const payload = await getUserById(1).unwrap();
|
||||
* console.log('fulfilled', payload)
|
||||
* } catch (error) {
|
||||
* console.error('rejected', error);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
(arg: QueryArgFrom<D>, direction: InfiniteQueryDirection): InfiniteQueryActionCreatorResult<D>;
|
||||
};
|
||||
type TypedLazyInfiniteQueryTrigger<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = LazyInfiniteQueryTrigger<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
type UseInfiniteQuerySubscriptionOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>> = SubscriptionOptions & {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* // codeblock-meta no-transpile title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.
|
||||
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
||||
* - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.
|
||||
* - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.
|
||||
*
|
||||
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
||||
*/
|
||||
refetchOnMountOrArgChange?: boolean | number;
|
||||
initialPageParam?: PageParamFrom<D>;
|
||||
/**
|
||||
* Defaults to `true`. When this is `true` and an infinite query endpoint is refetched
|
||||
* (due to tag invalidation, polling, arg change configuration, or manual refetching),
|
||||
* RTK Query will try to sequentially refetch all pages currently in the cache.
|
||||
* When `false` only the first page will be refetched.
|
||||
*
|
||||
* This option applies to all automatic refetches for this subscription (polling, tag invalidation, etc.).
|
||||
* It can be overridden on a per-call basis using the `refetch()` method.
|
||||
*/
|
||||
refetchCachedPages?: boolean;
|
||||
};
|
||||
type TypedUseInfiniteQuerySubscription<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscription<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
type UseInfiniteQuerySubscriptionResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
||||
refetch: (options?: Pick<UseInfiniteQuerySubscriptionOptions<D>, 'refetchCachedPages'>) => InfiniteQueryActionCreatorResult<D>;
|
||||
trigger: LazyInfiniteQueryTrigger<D>;
|
||||
fetchNextPage: () => InfiniteQueryActionCreatorResult<D>;
|
||||
fetchPreviousPage: () => InfiniteQueryActionCreatorResult<D>;
|
||||
};
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useQuerySubscription` hook in userland code.
|
||||
*/
|
||||
type TypedUseInfiniteQuerySubscriptionResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscriptionResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
type InfiniteQueryStateSelector<R extends Record<string, any>, D extends InfiniteQueryDefinition<any, any, any, any, any>> = (state: UseInfiniteQueryStateDefaultResult<D>) => R;
|
||||
type TypedInfiniteQueryStateSelector<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = InfiniteQueryStateSelector<SelectedResult, InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available. Additionally, it will cache multiple "pages" worth of responses within a single cache entry, and allows fetching more pages forwards and backwards from the current cached pages.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.
|
||||
*
|
||||
* The `data` field will be a `{pages: Data[], pageParams: PageParam[]}` structure containing all fetched page responses and the corresponding page param values for each page. You may use this to render individual pages, combine all pages into a single infinite list, or other display logic as needed.
|
||||
*
|
||||
* This hook combines the functionality of both [`useInfiniteQueryState`](#useinfinitequerystate) and [`useInfiniteQuerySubscription`](#useinfinitequerysubscription) together, and is intended to be used in the majority of situations.
|
||||
*
|
||||
* As with normal query hooks, `skipToken` is a valid argument that will skip the query from executing.
|
||||
*
|
||||
* By default, the initial request will use the `initialPageParam` value that was defined on the infinite query endpoint. If you want to start from a different value, you can pass `initialPageParam` as part of the hook options to override that initial request value.
|
||||
*
|
||||
* Use the returned `fetchNextPage` and `fetchPreviousPage` methods on the hook result object to trigger fetches forwards and backwards. These will always calculate the next or previous page param based on the current cached pages and the provided `getNext/PreviousPageParam` callbacks defined in the endpoint.
|
||||
*
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseInfiniteQuery<D extends InfiniteQueryDefinition<any, any, any, any, any>> = <R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<D>>(arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D> & UseInfiniteQueryStateOptions<D, R>) => UseInfiniteQueryHookResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'fetchNextPage' | 'fetchPreviousPage'>;
|
||||
type TypedUseInfiniteQuery<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuery<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
|
||||
*
|
||||
* Note that this hook does not trigger fetching new data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQuerySubscription`](#useinfinitequerysubscription).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseInfiniteQueryState<D extends InfiniteQueryDefinition<any, any, any, any, any>> = <R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<D>>(arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQueryStateOptions<D, R>) => UseInfiniteQueryStateResult<D, R>;
|
||||
type TypedUseInfiniteQueryState<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQueryState<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
||||
/**
|
||||
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data. Additionally, it will cache multiple "pages" worth of responses within a single cache entry, and allows fetching more pages forwards and backwards from the current cached pages.
|
||||
*
|
||||
* The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.
|
||||
*
|
||||
* Note that this hook does not return a request status or cached data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQueryState`](#useinfinitequerystate).
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
||||
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
||||
*/
|
||||
type UseInfiniteQuerySubscription<D extends InfiniteQueryDefinition<any, any, any, any, any>> = (arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D>) => UseInfiniteQuerySubscriptionResult<D>;
|
||||
type UseInfiniteQueryHookResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = UseInfiniteQueryStateResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'refetch' | 'fetchNextPage' | 'fetchPreviousPage'>;
|
||||
type TypedUseInfiniteQueryHookResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryHookResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, R>;
|
||||
type UseInfiniteQueryStateOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>, R extends Record<string, any>> = {
|
||||
/**
|
||||
* Prevents a query from automatically running.
|
||||
*
|
||||
* @remarks
|
||||
* When skip is true:
|
||||
*
|
||||
* - **If the query has cached data:**
|
||||
* * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
||||
* - **If the query does not have cached data:**
|
||||
* * The query will have a status of `uninitialized`
|
||||
* * The query will not exist in the state when viewed with the dev tools
|
||||
* * The query will not automatically fetch on mount
|
||||
* * The query will not automatically run when additional components with the same query are added that do run
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Skip example"
|
||||
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
||||
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
||||
* skip,
|
||||
* });
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {name} - {status}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
skip?: boolean;
|
||||
/**
|
||||
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
||||
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
||||
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
||||
* Note that this should always return an object (not a primitive), as RTKQ adds fields to the return value.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
||||
* function PostsList() {
|
||||
* const { data: posts } = api.useGetPostsQuery();
|
||||
*
|
||||
* return (
|
||||
* <ul>
|
||||
* {posts?.data?.map((post) => (
|
||||
* <PostById key={post.id} id={post.id} />
|
||||
* ))}
|
||||
* </ul>
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* function PostById({ id }: { id: number }) {
|
||||
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
||||
* const { post } = api.useGetPostsQuery(undefined, {
|
||||
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
||||
* });
|
||||
*
|
||||
* return <li>{post?.name}</li>;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
selectFromResult?: InfiniteQueryStateSelector<R, D>;
|
||||
};
|
||||
type TypedUseInfiniteQueryStateOptions<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryStateOptions<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, SelectedResult>;
|
||||
type UseInfiniteQueryStateResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = TSHelpersNoInfer<R>;
|
||||
type TypedUseInfiniteQueryStateResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, R = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryStateResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, R>;
|
||||
type UseInfiniteQueryStateBaseResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = InfiniteQuerySubState<D> & {
|
||||
/**
|
||||
* Where `data` tries to hold data as much as possible, also re-using
|
||||
* data from the last arguments passed into the hook, this property
|
||||
* will always contain the received data from the query, for the current query arguments.
|
||||
*/
|
||||
currentData?: InfiniteData<ResultTypeFrom<D>, PageParamFrom<D>>;
|
||||
/**
|
||||
* Query has not started yet.
|
||||
*/
|
||||
isUninitialized: false;
|
||||
/**
|
||||
* Query is currently loading for the first time. No data yet.
|
||||
*/
|
||||
isLoading: false;
|
||||
/**
|
||||
* Query is currently fetching, but might have data from an earlier request.
|
||||
*/
|
||||
isFetching: false;
|
||||
/**
|
||||
* Query has data from a successful load.
|
||||
*/
|
||||
isSuccess: false;
|
||||
/**
|
||||
* Query is currently in "error" state.
|
||||
*/
|
||||
isError: false;
|
||||
hasNextPage: boolean;
|
||||
hasPreviousPage: boolean;
|
||||
isFetchingNextPage: boolean;
|
||||
isFetchingPreviousPage: boolean;
|
||||
};
|
||||
type UseInfiniteQueryStateDefaultResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseInfiniteQueryStateBaseResult<D>, {
|
||||
status: QueryStatus.uninitialized;
|
||||
}>, {
|
||||
isUninitialized: true;
|
||||
}> | TSHelpersOverride<UseInfiniteQueryStateBaseResult<D>, {
|
||||
isLoading: true;
|
||||
isFetching: boolean;
|
||||
data: undefined;
|
||||
} | ({
|
||||
isSuccess: true;
|
||||
isFetching: true;
|
||||
error: undefined;
|
||||
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
|
||||
isSuccess: true;
|
||||
isFetching: false;
|
||||
error: undefined;
|
||||
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
|
||||
isError: true;
|
||||
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'error'>>)>> & {
|
||||
/**
|
||||
* @deprecated Included for completeness, but discouraged.
|
||||
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
||||
* and `isUninitialized` flags instead
|
||||
*/
|
||||
status: QueryStatus;
|
||||
};
|
||||
type MutationStateSelector<R extends Record<string, any>, D extends MutationDefinition<any, any, any, any>> = (state: MutationResultSelectorResult<D>) => R;
|
||||
type UseMutationStateOptions<D extends MutationDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
||||
selectFromResult?: MutationStateSelector<R, D>;
|
||||
fixedCacheKey?: string;
|
||||
};
|
||||
type UseMutationStateResult<D extends MutationDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R> & {
|
||||
originalArgs?: QueryArgFrom<D>;
|
||||
/**
|
||||
* Resets the hook state to its initial `uninitialized` state.
|
||||
* This will also remove the last result from the cache.
|
||||
*/
|
||||
reset: () => void;
|
||||
};
|
||||
/**
|
||||
* Helper type to manually type the result
|
||||
* of the `useMutation` hook in userland code.
|
||||
*/
|
||||
type TypedUseMutationResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = MutationResultSelectorResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseMutationStateResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
||||
/**
|
||||
* A React hook that lets you trigger an update request for a given endpoint, and subscribes the component to read the request status from the Redux store. The component will re-render as the loading status changes.
|
||||
*
|
||||
* #### Features
|
||||
*
|
||||
* - Manual control over firing a request to alter data on the server or possibly invalidate the cache
|
||||
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
||||
* - Returns the latest request status and cached data from the Redux store
|
||||
* - Re-renders as the request status changes and data becomes available
|
||||
*/
|
||||
type UseMutation<D extends MutationDefinition<any, any, any, any>> = <R extends Record<string, any> = MutationResultSelectorResult<D>>(options?: UseMutationStateOptions<D, R>) => readonly [MutationTrigger<D>, UseMutationStateResult<D, R>];
|
||||
type TypedUseMutation<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseMutation<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
type MutationTrigger<D extends MutationDefinition<any, any, any, any>> = {
|
||||
/**
|
||||
* Triggers the mutation and returns a Promise.
|
||||
* @remarks
|
||||
* If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // codeblock-meta title="Using .unwrap with async await"
|
||||
* try {
|
||||
* const payload = await addPost({ id: 1, name: 'Example' }).unwrap();
|
||||
* console.log('fulfilled', payload)
|
||||
* } catch (error) {
|
||||
* console.error('rejected', error);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
(arg: QueryArgFrom<D>): MutationActionCreatorResult<D>;
|
||||
};
|
||||
type TypedMutationTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = MutationTrigger<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
||||
|
||||
type QueryHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.query;
|
||||
} ? `use${Capitalize<K & string>}Query` : never]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
||||
};
|
||||
type LazyQueryHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.query;
|
||||
} ? `useLazy${Capitalize<K & string>}Query` : never]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
||||
};
|
||||
type InfiniteQueryHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.infinitequery;
|
||||
} ? `use${Capitalize<K & string>}InfiniteQuery` : never]: UseInfiniteQuery<Extract<Definitions[K], InfiniteQueryDefinition<any, any, any, any, any>>>;
|
||||
};
|
||||
type MutationHookNames<Definitions extends EndpointDefinitions> = {
|
||||
[K in keyof Definitions as Definitions[K] extends {
|
||||
type: DefinitionType.mutation;
|
||||
} ? `use${Capitalize<K & string>}Mutation` : never]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
|
||||
};
|
||||
type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = QueryHookNames<Definitions> & LazyQueryHookNames<Definitions> & InfiniteQueryHookNames<Definitions> & MutationHookNames<Definitions>;
|
||||
|
||||
export declare const reactHooksModuleName: unique symbol;
|
||||
type ReactHooksModule = typeof reactHooksModuleName;
|
||||
declare module '@reduxjs/toolkit/query' {
|
||||
interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
|
||||
[reactHooksModuleName]: {
|
||||
/**
|
||||
* Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.
|
||||
*/
|
||||
endpoints: {
|
||||
[K in keyof Definitions]: Definitions[K] extends QueryDefinition<any, any, any, any, any> ? QueryHooks<Definitions[K]> : Definitions[K] extends MutationDefinition<any, any, any, any, any> ? MutationHooks<Definitions[K]> : Definitions[K] extends InfiniteQueryDefinition<any, any, any, any, any> ? InfiniteQueryHooks<Definitions[K]> : never;
|
||||
};
|
||||
/**
|
||||
* A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.
|
||||
*/
|
||||
usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
|
||||
} & HooksWithUniqueNames<Definitions>;
|
||||
}
|
||||
}
|
||||
type RR = typeof react_redux;
|
||||
interface ReactHooksModuleOptions {
|
||||
/**
|
||||
* The hooks from React Redux to be used
|
||||
*/
|
||||
hooks?: {
|
||||
/**
|
||||
* The version of the `useDispatch` hook to be used
|
||||
*/
|
||||
useDispatch: RR['useDispatch'];
|
||||
/**
|
||||
* The version of the `useSelector` hook to be used
|
||||
*/
|
||||
useSelector: RR['useSelector'];
|
||||
/**
|
||||
* The version of the `useStore` hook to be used
|
||||
*/
|
||||
useStore: RR['useStore'];
|
||||
};
|
||||
/**
|
||||
* The version of the `batchedUpdates` function to be used
|
||||
*/
|
||||
batch?: RR['batch'];
|
||||
/**
|
||||
* Enables performing asynchronous tasks immediately within a render.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import {
|
||||
* buildCreateApi,
|
||||
* coreModule,
|
||||
* reactHooksModule
|
||||
* } from '@reduxjs/toolkit/query/react'
|
||||
*
|
||||
* const createApi = buildCreateApi(
|
||||
* coreModule(),
|
||||
* reactHooksModule({ unstable__sideEffectsInRender: true })
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
unstable__sideEffectsInRender?: boolean;
|
||||
/**
|
||||
* A selector creator (usually from `reselect`, or matching the same signature)
|
||||
*/
|
||||
createSelector?: CreateSelectorFunction<any, any, any>;
|
||||
}
|
||||
/**
|
||||
* Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const MyContext = React.createContext<ReactReduxContextValue | null>(null);
|
||||
* const customCreateApi = buildCreateApi(
|
||||
* coreModule(),
|
||||
* reactHooksModule({
|
||||
* hooks: {
|
||||
* useDispatch: createDispatchHook(MyContext),
|
||||
* useSelector: createSelectorHook(MyContext),
|
||||
* useStore: createStoreHook(MyContext)
|
||||
* }
|
||||
* })
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @returns A module for use with `buildCreateApi`
|
||||
*/
|
||||
declare const reactHooksModule: ({ batch, hooks, createSelector, unstable__sideEffectsInRender, ...rest }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
|
||||
|
||||
/**
|
||||
* Can be used as a `Provider` if you **do not already have a Redux store**.
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* // codeblock-meta no-transpile title="Basic usage - wrap your App with ApiProvider"
|
||||
* import * as React from 'react';
|
||||
* import { ApiProvider } from '@reduxjs/toolkit/query/react';
|
||||
* import { Pokemon } from './features/Pokemon';
|
||||
*
|
||||
* function App() {
|
||||
* return (
|
||||
* <ApiProvider api={api}>
|
||||
* <Pokemon />
|
||||
* </ApiProvider>
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* Using this together with an existing redux store, both will
|
||||
* conflict with each other - please use the traditional redux setup
|
||||
* in that case.
|
||||
*/
|
||||
declare function ApiProvider(props: {
|
||||
children: any;
|
||||
api: Api<any, {}, any, any>;
|
||||
setupListeners?: Parameters<typeof setupListeners>[1] | false;
|
||||
context?: Context<ReactReduxContextValue | null>;
|
||||
}): React.JSX.Element;
|
||||
|
||||
declare const createApi: _reduxjs_toolkit_query.CreateApi<typeof _reduxjs_toolkit_query.coreModuleName | typeof reactHooksModuleName>;
|
||||
|
||||
export { ApiProvider, type TypedInfiniteQueryStateSelector, type TypedLazyInfiniteQueryTrigger, type TypedLazyQueryTrigger, type TypedMutationTrigger, type TypedQueryStateSelector, type TypedUseInfiniteQuery, type TypedUseInfiniteQueryHookResult, type TypedUseInfiniteQueryState, type TypedUseInfiniteQueryStateOptions, type TypedUseInfiniteQueryStateResult, type TypedUseInfiniteQuerySubscription, type TypedUseInfiniteQuerySubscriptionResult, type TypedUseLazyQuery, type TypedUseLazyQueryStateResult, type TypedUseLazyQuerySubscription, type TypedUseMutation, type TypedUseMutationResult, type TypedUseQuery, type TypedUseQueryHookResult, type TypedUseQueryState, type TypedUseQueryStateOptions, type TypedUseQueryStateResult, type TypedUseQuerySubscription, type TypedUseQuerySubscriptionResult, createApi, reactHooksModule };
|
||||
2
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs
generated
vendored
Normal file
2
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
740
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js
generated
vendored
Normal file
740
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js
generated
vendored
Normal file
@@ -0,0 +1,740 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
var __objRest = (source, exclude) => {
|
||||
var target = {};
|
||||
for (var prop in source)
|
||||
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
||||
target[prop] = source[prop];
|
||||
if (source != null && __getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(source)) {
|
||||
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
// src/query/react/rtkqImports.ts
|
||||
import { buildCreateApi, coreModule, copyWithStructuralSharing, setupListeners, QueryStatus, skipToken } from "@reduxjs/toolkit/query";
|
||||
|
||||
// src/query/react/module.ts
|
||||
import { formatProdErrorMessage as _formatProdErrorMessage4 } from "@reduxjs/toolkit";
|
||||
import { batch as rrBatch, useDispatch as rrUseDispatch, useSelector as rrUseSelector, useStore as rrUseStore } from "react-redux";
|
||||
import { createSelector as _createSelector } from "reselect";
|
||||
|
||||
// src/query/utils/capitalize.ts
|
||||
function capitalize(str) {
|
||||
return str.replace(str[0], str[0].toUpperCase());
|
||||
}
|
||||
|
||||
// src/query/utils/countObjectKeys.ts
|
||||
function countObjectKeys(obj) {
|
||||
let count = 0;
|
||||
for (const _key in obj) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// src/query/endpointDefinitions.ts
|
||||
var ENDPOINT_QUERY = "query" /* query */;
|
||||
var ENDPOINT_MUTATION = "mutation" /* mutation */;
|
||||
var ENDPOINT_INFINITEQUERY = "infinitequery" /* infinitequery */;
|
||||
function isQueryDefinition(e) {
|
||||
return e.type === ENDPOINT_QUERY;
|
||||
}
|
||||
function isMutationDefinition(e) {
|
||||
return e.type === ENDPOINT_MUTATION;
|
||||
}
|
||||
function isInfiniteQueryDefinition(e) {
|
||||
return e.type === ENDPOINT_INFINITEQUERY;
|
||||
}
|
||||
|
||||
// src/query/tsHelpers.ts
|
||||
function safeAssign(target, ...args) {
|
||||
return Object.assign(target, ...args);
|
||||
}
|
||||
|
||||
// src/query/react/buildHooks.ts
|
||||
import { formatProdErrorMessage as _formatProdErrorMessage, formatProdErrorMessage as _formatProdErrorMessage2, formatProdErrorMessage as _formatProdErrorMessage3 } from "@reduxjs/toolkit";
|
||||
|
||||
// src/query/react/reactImports.ts
|
||||
import { useEffect, useRef, useMemo, useContext, useCallback, useDebugValue, useLayoutEffect, useState } from "react";
|
||||
|
||||
// src/query/react/reactReduxImports.ts
|
||||
import { shallowEqual, Provider, ReactReduxContext } from "react-redux";
|
||||
|
||||
// src/query/react/constants.ts
|
||||
var UNINITIALIZED_VALUE = Symbol();
|
||||
|
||||
// src/query/react/useSerializedStableValue.ts
|
||||
function useStableQueryArgs(queryArgs) {
|
||||
const cache = useRef(queryArgs);
|
||||
const copy = useMemo(() => copyWithStructuralSharing(cache.current, queryArgs), [queryArgs]);
|
||||
useEffect(() => {
|
||||
if (cache.current !== copy) {
|
||||
cache.current = copy;
|
||||
}
|
||||
}, [copy]);
|
||||
return copy;
|
||||
}
|
||||
|
||||
// src/query/react/useShallowStableValue.ts
|
||||
function useShallowStableValue(value) {
|
||||
const cache = useRef(value);
|
||||
useEffect(() => {
|
||||
if (!shallowEqual(cache.current, value)) {
|
||||
cache.current = value;
|
||||
}
|
||||
}, [value]);
|
||||
return shallowEqual(cache.current, value) ? cache.current : value;
|
||||
}
|
||||
|
||||
// src/query/react/buildHooks.ts
|
||||
var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
||||
var isDOM = /* @__PURE__ */ canUseDOM();
|
||||
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
||||
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
||||
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? useLayoutEffect : useEffect;
|
||||
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
||||
var noPendingQueryStateSelector = (selected) => {
|
||||
if (selected.isUninitialized) {
|
||||
return __spreadProps(__spreadValues({}, selected), {
|
||||
isUninitialized: false,
|
||||
isFetching: true,
|
||||
isLoading: selected.data !== void 0 ? false : true,
|
||||
// This is the one place where we still have to use `QueryStatus` as an enum,
|
||||
// since it's the only reference in the React package and not in the core.
|
||||
status: QueryStatus.pending
|
||||
});
|
||||
}
|
||||
return selected;
|
||||
};
|
||||
function pick(obj, ...keys) {
|
||||
const ret = {};
|
||||
keys.forEach((key) => {
|
||||
ret[key] = obj[key];
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
|
||||
function buildHooks({
|
||||
api,
|
||||
moduleOptions: {
|
||||
batch,
|
||||
hooks: {
|
||||
useDispatch,
|
||||
useSelector,
|
||||
useStore
|
||||
},
|
||||
unstable__sideEffectsInRender,
|
||||
createSelector
|
||||
},
|
||||
serializeQueryArgs,
|
||||
context
|
||||
}) {
|
||||
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : useEffect;
|
||||
const unsubscribePromiseRef = (ref) => {
|
||||
var _a, _b;
|
||||
return (_b = (_a = ref.current) == null ? void 0 : _a.unsubscribe) == null ? void 0 : _b.call(_a);
|
||||
};
|
||||
const endpointDefinitions = context.endpointDefinitions;
|
||||
return {
|
||||
buildQueryHooks,
|
||||
buildInfiniteQueryHooks,
|
||||
buildMutationHook,
|
||||
usePrefetch
|
||||
};
|
||||
function queryStatePreSelector(currentState, lastResult, queryArgs) {
|
||||
if ((lastResult == null ? void 0 : lastResult.endpointName) && currentState.isUninitialized) {
|
||||
const {
|
||||
endpointName
|
||||
} = lastResult;
|
||||
const endpointDefinition = endpointDefinitions[endpointName];
|
||||
if (queryArgs !== skipToken && serializeQueryArgs({
|
||||
queryArgs: lastResult.originalArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
}) === serializeQueryArgs({
|
||||
queryArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
})) lastResult = void 0;
|
||||
}
|
||||
let data = currentState.isSuccess ? currentState.data : lastResult == null ? void 0 : lastResult.data;
|
||||
if (data === void 0) data = currentState.data;
|
||||
const hasData = data !== void 0;
|
||||
const isFetching = currentState.isLoading;
|
||||
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
||||
const isSuccess = currentState.isSuccess || hasData && (isFetching && !(lastResult == null ? void 0 : lastResult.isError) || currentState.isUninitialized);
|
||||
return __spreadProps(__spreadValues({}, currentState), {
|
||||
data,
|
||||
currentData: currentState.data,
|
||||
isFetching,
|
||||
isLoading,
|
||||
isSuccess
|
||||
});
|
||||
}
|
||||
function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
|
||||
if ((lastResult == null ? void 0 : lastResult.endpointName) && currentState.isUninitialized) {
|
||||
const {
|
||||
endpointName
|
||||
} = lastResult;
|
||||
const endpointDefinition = endpointDefinitions[endpointName];
|
||||
if (queryArgs !== skipToken && serializeQueryArgs({
|
||||
queryArgs: lastResult.originalArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
}) === serializeQueryArgs({
|
||||
queryArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
})) lastResult = void 0;
|
||||
}
|
||||
let data = currentState.isSuccess ? currentState.data : lastResult == null ? void 0 : lastResult.data;
|
||||
if (data === void 0) data = currentState.data;
|
||||
const hasData = data !== void 0;
|
||||
const isFetching = currentState.isLoading;
|
||||
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
||||
const isSuccess = currentState.isSuccess || isFetching && hasData;
|
||||
return __spreadProps(__spreadValues({}, currentState), {
|
||||
data,
|
||||
currentData: currentState.data,
|
||||
isFetching,
|
||||
isLoading,
|
||||
isSuccess
|
||||
});
|
||||
}
|
||||
function usePrefetch(endpointName, defaultOptions) {
|
||||
const dispatch = useDispatch();
|
||||
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
||||
return useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, __spreadValues(__spreadValues({}, stableDefaultOptions), options))), [endpointName, dispatch, stableDefaultOptions]);
|
||||
}
|
||||
function useQuerySubscriptionCommonImpl(endpointName, arg, _a = {}) {
|
||||
var _b = _a, {
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
refetchOnMountOrArgChange,
|
||||
skip = false,
|
||||
pollingInterval = 0,
|
||||
skipPollingIfUnfocused = false
|
||||
} = _b, rest = __objRest(_b, [
|
||||
"refetchOnReconnect",
|
||||
"refetchOnFocus",
|
||||
"refetchOnMountOrArgChange",
|
||||
"skip",
|
||||
"pollingInterval",
|
||||
"skipPollingIfUnfocused"
|
||||
]);
|
||||
const {
|
||||
initiate
|
||||
} = api.endpoints[endpointName];
|
||||
const dispatch = useDispatch();
|
||||
const subscriptionSelectorsRef = useRef(void 0);
|
||||
if (!subscriptionSelectorsRef.current) {
|
||||
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (typeof returnedValue !== "object" || typeof (returnedValue == null ? void 0 : returnedValue.type) === "string") {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage(37) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
|
||||
You must add the middleware for RTK-Query to function correctly!`);
|
||||
}
|
||||
}
|
||||
subscriptionSelectorsRef.current = returnedValue;
|
||||
}
|
||||
const stableArg = useStableQueryArgs(skip ? skipToken : arg);
|
||||
const stableSubscriptionOptions = useShallowStableValue({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval,
|
||||
skipPollingIfUnfocused
|
||||
});
|
||||
const initialPageParam = rest.initialPageParam;
|
||||
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
||||
const refetchCachedPages = rest.refetchCachedPages;
|
||||
const stableRefetchCachedPages = useShallowStableValue(refetchCachedPages);
|
||||
const promiseRef = useRef(void 0);
|
||||
let {
|
||||
queryCacheKey,
|
||||
requestId
|
||||
} = promiseRef.current || {};
|
||||
let currentRenderHasSubscription = false;
|
||||
if (queryCacheKey && requestId) {
|
||||
currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
|
||||
}
|
||||
const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
|
||||
usePossiblyImmediateEffect(() => {
|
||||
if (subscriptionRemoved) {
|
||||
promiseRef.current = void 0;
|
||||
}
|
||||
}, [subscriptionRemoved]);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
var _a2;
|
||||
const lastPromise = promiseRef.current;
|
||||
if (typeof process !== "undefined" && process.env.NODE_ENV === "removeMeOnCompilation") {
|
||||
console.log(subscriptionRemoved);
|
||||
}
|
||||
if (stableArg === skipToken) {
|
||||
lastPromise == null ? void 0 : lastPromise.unsubscribe();
|
||||
promiseRef.current = void 0;
|
||||
return;
|
||||
}
|
||||
const lastSubscriptionOptions = (_a2 = promiseRef.current) == null ? void 0 : _a2.subscriptionOptions;
|
||||
if (!lastPromise || lastPromise.arg !== stableArg) {
|
||||
lastPromise == null ? void 0 : lastPromise.unsubscribe();
|
||||
const promise = dispatch(initiate(stableArg, __spreadValues({
|
||||
subscriptionOptions: stableSubscriptionOptions,
|
||||
forceRefetch: refetchOnMountOrArgChange
|
||||
}, isInfiniteQueryDefinition(endpointDefinitions[endpointName]) ? {
|
||||
initialPageParam: stableInitialPageParam,
|
||||
refetchCachedPages: stableRefetchCachedPages
|
||||
} : {})));
|
||||
promiseRef.current = promise;
|
||||
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
||||
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
|
||||
}
|
||||
}, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, stableRefetchCachedPages, endpointName]);
|
||||
return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
|
||||
}
|
||||
function buildUseQueryState(endpointName, preSelector) {
|
||||
const useQueryState = (arg, {
|
||||
skip = false,
|
||||
selectFromResult
|
||||
} = {}) => {
|
||||
const {
|
||||
select
|
||||
} = api.endpoints[endpointName];
|
||||
const stableArg = useStableQueryArgs(skip ? skipToken : arg);
|
||||
const lastValue = useRef(void 0);
|
||||
const selectDefaultResult = useMemo(() => (
|
||||
// Normally ts-ignores are bad and should be avoided, but we're
|
||||
// already casting this selector to be `Selector<any>` anyway,
|
||||
// so the inconsistencies don't matter here
|
||||
// @ts-ignore
|
||||
createSelector([
|
||||
// @ts-ignore
|
||||
select(stableArg),
|
||||
(_, lastResult) => lastResult,
|
||||
(_) => stableArg
|
||||
], preSelector, {
|
||||
memoizeOptions: {
|
||||
resultEqualityCheck: shallowEqual
|
||||
}
|
||||
})
|
||||
), [select, stableArg]);
|
||||
const querySelector = useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
||||
devModeChecks: {
|
||||
identityFunctionCheck: "never"
|
||||
}
|
||||
}) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
|
||||
const currentState = useSelector((state) => querySelector(state, lastValue.current), shallowEqual);
|
||||
const store = useStore();
|
||||
const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
lastValue.current = newLastValue;
|
||||
}, [newLastValue]);
|
||||
return currentState;
|
||||
};
|
||||
return useQueryState;
|
||||
}
|
||||
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = void 0;
|
||||
};
|
||||
}, [promiseRef]);
|
||||
}
|
||||
function refetchOrErrorIfUnmounted(promiseRef) {
|
||||
if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
|
||||
return promiseRef.current.refetch();
|
||||
}
|
||||
function buildQueryHooks(endpointName) {
|
||||
const useQuerySubscription = (arg, options = {}) => {
|
||||
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
||||
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
||||
return useMemo(() => ({
|
||||
/**
|
||||
* A method to manually refetch data for the query
|
||||
*/
|
||||
refetch: () => refetchOrErrorIfUnmounted(promiseRef)
|
||||
}), [promiseRef]);
|
||||
};
|
||||
const useLazyQuerySubscription = ({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval = 0,
|
||||
skipPollingIfUnfocused = false
|
||||
} = {}) => {
|
||||
const {
|
||||
initiate
|
||||
} = api.endpoints[endpointName];
|
||||
const dispatch = useDispatch();
|
||||
const [arg, setArg] = useState(UNINITIALIZED_VALUE);
|
||||
const promiseRef = useRef(void 0);
|
||||
const stableSubscriptionOptions = useShallowStableValue({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval,
|
||||
skipPollingIfUnfocused
|
||||
});
|
||||
usePossiblyImmediateEffect(() => {
|
||||
var _a, _b;
|
||||
const lastSubscriptionOptions = (_a = promiseRef.current) == null ? void 0 : _a.subscriptionOptions;
|
||||
if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
||||
(_b = promiseRef.current) == null ? void 0 : _b.updateSubscriptionOptions(stableSubscriptionOptions);
|
||||
}
|
||||
}, [stableSubscriptionOptions]);
|
||||
const subscriptionOptionsRef = useRef(stableSubscriptionOptions);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
||||
}, [stableSubscriptionOptions]);
|
||||
const trigger = useCallback(function(arg2, preferCacheValue = false) {
|
||||
let promise;
|
||||
batch(() => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = promise = dispatch(initiate(arg2, {
|
||||
subscriptionOptions: subscriptionOptionsRef.current,
|
||||
forceRefetch: !preferCacheValue
|
||||
}));
|
||||
setArg(arg2);
|
||||
});
|
||||
return promise;
|
||||
}, [dispatch, initiate]);
|
||||
const reset = useCallback(() => {
|
||||
var _a, _b;
|
||||
if ((_a = promiseRef.current) == null ? void 0 : _a.queryCacheKey) {
|
||||
dispatch(api.internalActions.removeQueryResult({
|
||||
queryCacheKey: (_b = promiseRef.current) == null ? void 0 : _b.queryCacheKey
|
||||
}));
|
||||
}
|
||||
}, [dispatch]);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
};
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
||||
trigger(arg, true);
|
||||
}
|
||||
}, [arg, trigger]);
|
||||
return useMemo(() => [trigger, arg, {
|
||||
reset
|
||||
}], [trigger, arg, reset]);
|
||||
};
|
||||
const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
|
||||
return {
|
||||
useQueryState,
|
||||
useQuerySubscription,
|
||||
useLazyQuerySubscription,
|
||||
useLazyQuery(options) {
|
||||
const [trigger, arg, {
|
||||
reset
|
||||
}] = useLazyQuerySubscription(options);
|
||||
const queryStateResults = useQueryState(arg, __spreadProps(__spreadValues({}, options), {
|
||||
skip: arg === UNINITIALIZED_VALUE
|
||||
}));
|
||||
const info = useMemo(() => ({
|
||||
lastArg: arg
|
||||
}), [arg]);
|
||||
return useMemo(() => [trigger, __spreadProps(__spreadValues({}, queryStateResults), {
|
||||
reset
|
||||
}), info], [trigger, queryStateResults, reset, info]);
|
||||
},
|
||||
useQuery(arg, options) {
|
||||
const querySubscriptionResults = useQuerySubscription(arg, options);
|
||||
const queryStateResults = useQueryState(arg, __spreadValues({
|
||||
selectFromResult: arg === skipToken || (options == null ? void 0 : options.skip) ? void 0 : noPendingQueryStateSelector
|
||||
}, options));
|
||||
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
||||
useDebugValue(debugValue);
|
||||
return useMemo(() => __spreadValues(__spreadValues({}, queryStateResults), querySubscriptionResults), [queryStateResults, querySubscriptionResults]);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildInfiniteQueryHooks(endpointName) {
|
||||
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
||||
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
||||
const subscriptionOptionsRef = useRef(stableSubscriptionOptions);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
||||
}, [stableSubscriptionOptions]);
|
||||
const hookRefetchCachedPages = options.refetchCachedPages;
|
||||
const stableHookRefetchCachedPages = useShallowStableValue(hookRefetchCachedPages);
|
||||
const trigger = useCallback(function(arg2, direction) {
|
||||
let promise;
|
||||
batch(() => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = promise = dispatch(initiate(arg2, {
|
||||
subscriptionOptions: subscriptionOptionsRef.current,
|
||||
direction
|
||||
}));
|
||||
});
|
||||
return promise;
|
||||
}, [promiseRef, dispatch, initiate]);
|
||||
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
||||
const stableArg = useStableQueryArgs(options.skip ? skipToken : arg);
|
||||
const refetch = useCallback((options2) => {
|
||||
var _a;
|
||||
if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage3(38) : "Cannot refetch a query that has not been started yet.");
|
||||
const mergedOptions = {
|
||||
refetchCachedPages: (_a = options2 == null ? void 0 : options2.refetchCachedPages) != null ? _a : stableHookRefetchCachedPages
|
||||
};
|
||||
return promiseRef.current.refetch(mergedOptions);
|
||||
}, [promiseRef, stableHookRefetchCachedPages]);
|
||||
return useMemo(() => {
|
||||
const fetchNextPage = () => {
|
||||
return trigger(stableArg, "forward");
|
||||
};
|
||||
const fetchPreviousPage = () => {
|
||||
return trigger(stableArg, "backward");
|
||||
};
|
||||
return {
|
||||
trigger,
|
||||
/**
|
||||
* A method to manually refetch data for the query
|
||||
*/
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage
|
||||
};
|
||||
}, [refetch, trigger, stableArg]);
|
||||
};
|
||||
const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
|
||||
return {
|
||||
useInfiniteQueryState,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQuery(arg, options) {
|
||||
const {
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage
|
||||
} = useInfiniteQuerySubscription(arg, options);
|
||||
const queryStateResults = useInfiniteQueryState(arg, __spreadValues({
|
||||
selectFromResult: arg === skipToken || (options == null ? void 0 : options.skip) ? void 0 : noPendingQueryStateSelector
|
||||
}, options));
|
||||
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
||||
useDebugValue(debugValue);
|
||||
return useMemo(() => __spreadProps(__spreadValues({}, queryStateResults), {
|
||||
fetchNextPage,
|
||||
fetchPreviousPage,
|
||||
refetch
|
||||
}), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildMutationHook(name) {
|
||||
return ({
|
||||
selectFromResult,
|
||||
fixedCacheKey
|
||||
} = {}) => {
|
||||
const {
|
||||
select,
|
||||
initiate
|
||||
} = api.endpoints[name];
|
||||
const dispatch = useDispatch();
|
||||
const [promise, setPromise] = useState();
|
||||
useEffect(() => () => {
|
||||
if (!(promise == null ? void 0 : promise.arg.fixedCacheKey)) {
|
||||
promise == null ? void 0 : promise.reset();
|
||||
}
|
||||
}, [promise]);
|
||||
const triggerMutation = useCallback(function(arg) {
|
||||
const promise2 = dispatch(initiate(arg, {
|
||||
fixedCacheKey
|
||||
}));
|
||||
setPromise(promise2);
|
||||
return promise2;
|
||||
}, [dispatch, initiate, fixedCacheKey]);
|
||||
const {
|
||||
requestId
|
||||
} = promise || {};
|
||||
const selectDefaultResult = useMemo(() => select({
|
||||
fixedCacheKey,
|
||||
requestId: promise == null ? void 0 : promise.requestId
|
||||
}), [fixedCacheKey, promise, select]);
|
||||
const mutationSelector = useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
||||
const currentState = useSelector(mutationSelector, shallowEqual);
|
||||
const originalArgs = fixedCacheKey == null ? promise == null ? void 0 : promise.arg.originalArgs : void 0;
|
||||
const reset = useCallback(() => {
|
||||
batch(() => {
|
||||
if (promise) {
|
||||
setPromise(void 0);
|
||||
}
|
||||
if (fixedCacheKey) {
|
||||
dispatch(api.internalActions.removeMutationResult({
|
||||
requestId,
|
||||
fixedCacheKey
|
||||
}));
|
||||
}
|
||||
});
|
||||
}, [dispatch, fixedCacheKey, promise, requestId]);
|
||||
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
||||
useDebugValue(debugValue);
|
||||
const finalState = useMemo(() => __spreadProps(__spreadValues({}, currentState), {
|
||||
originalArgs,
|
||||
reset
|
||||
}), [currentState, originalArgs, reset]);
|
||||
return useMemo(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// src/query/react/module.ts
|
||||
var reactHooksModuleName = /* @__PURE__ */ Symbol();
|
||||
var reactHooksModule = (_a = {}) => {
|
||||
var _b = _a, {
|
||||
batch = rrBatch,
|
||||
hooks = {
|
||||
useDispatch: rrUseDispatch,
|
||||
useSelector: rrUseSelector,
|
||||
useStore: rrUseStore
|
||||
},
|
||||
createSelector = _createSelector,
|
||||
unstable__sideEffectsInRender = false
|
||||
} = _b, rest = __objRest(_b, [
|
||||
"batch",
|
||||
"hooks",
|
||||
"createSelector",
|
||||
"unstable__sideEffectsInRender"
|
||||
]);
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
const hookNames = ["useDispatch", "useSelector", "useStore"];
|
||||
let warned = false;
|
||||
for (const hookName of hookNames) {
|
||||
if (countObjectKeys(rest) > 0) {
|
||||
if (rest[hookName]) {
|
||||
if (!warned) {
|
||||
console.warn("As of RTK 2.0, the hooks now need to be specified as one object, provided under a `hooks` key:\n`reactHooksModule({ hooks: { useDispatch, useSelector, useStore } })`");
|
||||
warned = true;
|
||||
}
|
||||
}
|
||||
hooks[hookName] = rest[hookName];
|
||||
}
|
||||
if (typeof hooks[hookName] !== "function") {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage4(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(", ")}.
|
||||
Hook ${hookName} was either not provided or not a function.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
name: reactHooksModuleName,
|
||||
init(api, {
|
||||
serializeQueryArgs
|
||||
}, context) {
|
||||
const anyApi = api;
|
||||
const {
|
||||
buildQueryHooks,
|
||||
buildInfiniteQueryHooks,
|
||||
buildMutationHook,
|
||||
usePrefetch
|
||||
} = buildHooks({
|
||||
api,
|
||||
moduleOptions: {
|
||||
batch,
|
||||
hooks,
|
||||
unstable__sideEffectsInRender,
|
||||
createSelector
|
||||
},
|
||||
serializeQueryArgs,
|
||||
context
|
||||
});
|
||||
safeAssign(anyApi, {
|
||||
usePrefetch
|
||||
});
|
||||
safeAssign(context, {
|
||||
batch
|
||||
});
|
||||
return {
|
||||
injectEndpoint(endpointName, definition) {
|
||||
if (isQueryDefinition(definition)) {
|
||||
const {
|
||||
useQuery,
|
||||
useLazyQuery,
|
||||
useLazyQuerySubscription,
|
||||
useQueryState,
|
||||
useQuerySubscription
|
||||
} = buildQueryHooks(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useQuery,
|
||||
useLazyQuery,
|
||||
useLazyQuerySubscription,
|
||||
useQueryState,
|
||||
useQuerySubscription
|
||||
});
|
||||
api[`use${capitalize(endpointName)}Query`] = useQuery;
|
||||
api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
|
||||
}
|
||||
if (isMutationDefinition(definition)) {
|
||||
const useMutation = buildMutationHook(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useMutation
|
||||
});
|
||||
api[`use${capitalize(endpointName)}Mutation`] = useMutation;
|
||||
} else if (isInfiniteQueryDefinition(definition)) {
|
||||
const {
|
||||
useInfiniteQuery,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQueryState
|
||||
} = buildInfiniteQueryHooks(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useInfiniteQuery,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQueryState
|
||||
});
|
||||
api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// src/query/react/index.ts
|
||||
export * from "@reduxjs/toolkit/query";
|
||||
|
||||
// src/query/react/ApiProvider.tsx
|
||||
import { configureStore, formatProdErrorMessage as _formatProdErrorMessage5 } from "@reduxjs/toolkit";
|
||||
import * as React from "react";
|
||||
function ApiProvider(props) {
|
||||
const context = props.context || ReactReduxContext;
|
||||
const existingContext = useContext(context);
|
||||
if (existingContext) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage5(35) : "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.");
|
||||
}
|
||||
const [store] = React.useState(() => configureStore({
|
||||
reducer: {
|
||||
[props.api.reducerPath]: props.api.reducer
|
||||
},
|
||||
middleware: (gDM) => gDM().concat(props.api.middleware)
|
||||
}));
|
||||
useEffect(() => props.setupListeners === false ? void 0 : setupListeners(store.dispatch, props.setupListeners), [props.setupListeners, store.dispatch]);
|
||||
return /* @__PURE__ */ React.createElement(Provider, { store, context }, props.children);
|
||||
}
|
||||
|
||||
// src/query/react/index.ts
|
||||
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
||||
export {
|
||||
ApiProvider,
|
||||
UNINITIALIZED_VALUE,
|
||||
createApi,
|
||||
reactHooksModule,
|
||||
reactHooksModuleName
|
||||
};
|
||||
//# sourceMappingURL=rtk-query-react.legacy-esm.js.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
705
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs
generated
vendored
Normal file
705
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs
generated
vendored
Normal file
@@ -0,0 +1,705 @@
|
||||
// src/query/react/rtkqImports.ts
|
||||
import { buildCreateApi, coreModule, copyWithStructuralSharing, setupListeners, QueryStatus, skipToken } from "@reduxjs/toolkit/query";
|
||||
|
||||
// src/query/react/module.ts
|
||||
import { formatProdErrorMessage as _formatProdErrorMessage4 } from "@reduxjs/toolkit";
|
||||
import { batch as rrBatch, useDispatch as rrUseDispatch, useSelector as rrUseSelector, useStore as rrUseStore } from "react-redux";
|
||||
import { createSelector as _createSelector } from "reselect";
|
||||
|
||||
// src/query/utils/capitalize.ts
|
||||
function capitalize(str) {
|
||||
return str.replace(str[0], str[0].toUpperCase());
|
||||
}
|
||||
|
||||
// src/query/utils/countObjectKeys.ts
|
||||
function countObjectKeys(obj) {
|
||||
let count = 0;
|
||||
for (const _key in obj) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
// src/query/endpointDefinitions.ts
|
||||
var ENDPOINT_QUERY = "query" /* query */;
|
||||
var ENDPOINT_MUTATION = "mutation" /* mutation */;
|
||||
var ENDPOINT_INFINITEQUERY = "infinitequery" /* infinitequery */;
|
||||
function isQueryDefinition(e) {
|
||||
return e.type === ENDPOINT_QUERY;
|
||||
}
|
||||
function isMutationDefinition(e) {
|
||||
return e.type === ENDPOINT_MUTATION;
|
||||
}
|
||||
function isInfiniteQueryDefinition(e) {
|
||||
return e.type === ENDPOINT_INFINITEQUERY;
|
||||
}
|
||||
|
||||
// src/query/tsHelpers.ts
|
||||
function safeAssign(target, ...args) {
|
||||
return Object.assign(target, ...args);
|
||||
}
|
||||
|
||||
// src/query/react/buildHooks.ts
|
||||
import { formatProdErrorMessage as _formatProdErrorMessage, formatProdErrorMessage as _formatProdErrorMessage2, formatProdErrorMessage as _formatProdErrorMessage3 } from "@reduxjs/toolkit";
|
||||
|
||||
// src/query/react/reactImports.ts
|
||||
import { useEffect, useRef, useMemo, useContext, useCallback, useDebugValue, useLayoutEffect, useState } from "react";
|
||||
|
||||
// src/query/react/reactReduxImports.ts
|
||||
import { shallowEqual, Provider, ReactReduxContext } from "react-redux";
|
||||
|
||||
// src/query/react/constants.ts
|
||||
var UNINITIALIZED_VALUE = Symbol();
|
||||
|
||||
// src/query/react/useSerializedStableValue.ts
|
||||
function useStableQueryArgs(queryArgs) {
|
||||
const cache = useRef(queryArgs);
|
||||
const copy = useMemo(() => copyWithStructuralSharing(cache.current, queryArgs), [queryArgs]);
|
||||
useEffect(() => {
|
||||
if (cache.current !== copy) {
|
||||
cache.current = copy;
|
||||
}
|
||||
}, [copy]);
|
||||
return copy;
|
||||
}
|
||||
|
||||
// src/query/react/useShallowStableValue.ts
|
||||
function useShallowStableValue(value) {
|
||||
const cache = useRef(value);
|
||||
useEffect(() => {
|
||||
if (!shallowEqual(cache.current, value)) {
|
||||
cache.current = value;
|
||||
}
|
||||
}, [value]);
|
||||
return shallowEqual(cache.current, value) ? cache.current : value;
|
||||
}
|
||||
|
||||
// src/query/react/buildHooks.ts
|
||||
var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
||||
var isDOM = /* @__PURE__ */ canUseDOM();
|
||||
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
||||
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
||||
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? useLayoutEffect : useEffect;
|
||||
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
||||
var noPendingQueryStateSelector = (selected) => {
|
||||
if (selected.isUninitialized) {
|
||||
return {
|
||||
...selected,
|
||||
isUninitialized: false,
|
||||
isFetching: true,
|
||||
isLoading: selected.data !== void 0 ? false : true,
|
||||
// This is the one place where we still have to use `QueryStatus` as an enum,
|
||||
// since it's the only reference in the React package and not in the core.
|
||||
status: QueryStatus.pending
|
||||
};
|
||||
}
|
||||
return selected;
|
||||
};
|
||||
function pick(obj, ...keys) {
|
||||
const ret = {};
|
||||
keys.forEach((key) => {
|
||||
ret[key] = obj[key];
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
|
||||
function buildHooks({
|
||||
api,
|
||||
moduleOptions: {
|
||||
batch,
|
||||
hooks: {
|
||||
useDispatch,
|
||||
useSelector,
|
||||
useStore
|
||||
},
|
||||
unstable__sideEffectsInRender,
|
||||
createSelector
|
||||
},
|
||||
serializeQueryArgs,
|
||||
context
|
||||
}) {
|
||||
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : useEffect;
|
||||
const unsubscribePromiseRef = (ref) => ref.current?.unsubscribe?.();
|
||||
const endpointDefinitions = context.endpointDefinitions;
|
||||
return {
|
||||
buildQueryHooks,
|
||||
buildInfiniteQueryHooks,
|
||||
buildMutationHook,
|
||||
usePrefetch
|
||||
};
|
||||
function queryStatePreSelector(currentState, lastResult, queryArgs) {
|
||||
if (lastResult?.endpointName && currentState.isUninitialized) {
|
||||
const {
|
||||
endpointName
|
||||
} = lastResult;
|
||||
const endpointDefinition = endpointDefinitions[endpointName];
|
||||
if (queryArgs !== skipToken && serializeQueryArgs({
|
||||
queryArgs: lastResult.originalArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
}) === serializeQueryArgs({
|
||||
queryArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
})) lastResult = void 0;
|
||||
}
|
||||
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
||||
if (data === void 0) data = currentState.data;
|
||||
const hasData = data !== void 0;
|
||||
const isFetching = currentState.isLoading;
|
||||
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
||||
const isSuccess = currentState.isSuccess || hasData && (isFetching && !lastResult?.isError || currentState.isUninitialized);
|
||||
return {
|
||||
...currentState,
|
||||
data,
|
||||
currentData: currentState.data,
|
||||
isFetching,
|
||||
isLoading,
|
||||
isSuccess
|
||||
};
|
||||
}
|
||||
function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
|
||||
if (lastResult?.endpointName && currentState.isUninitialized) {
|
||||
const {
|
||||
endpointName
|
||||
} = lastResult;
|
||||
const endpointDefinition = endpointDefinitions[endpointName];
|
||||
if (queryArgs !== skipToken && serializeQueryArgs({
|
||||
queryArgs: lastResult.originalArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
}) === serializeQueryArgs({
|
||||
queryArgs,
|
||||
endpointDefinition,
|
||||
endpointName
|
||||
})) lastResult = void 0;
|
||||
}
|
||||
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
||||
if (data === void 0) data = currentState.data;
|
||||
const hasData = data !== void 0;
|
||||
const isFetching = currentState.isLoading;
|
||||
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
||||
const isSuccess = currentState.isSuccess || isFetching && hasData;
|
||||
return {
|
||||
...currentState,
|
||||
data,
|
||||
currentData: currentState.data,
|
||||
isFetching,
|
||||
isLoading,
|
||||
isSuccess
|
||||
};
|
||||
}
|
||||
function usePrefetch(endpointName, defaultOptions) {
|
||||
const dispatch = useDispatch();
|
||||
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
||||
return useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
|
||||
...stableDefaultOptions,
|
||||
...options
|
||||
})), [endpointName, dispatch, stableDefaultOptions]);
|
||||
}
|
||||
function useQuerySubscriptionCommonImpl(endpointName, arg, {
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
refetchOnMountOrArgChange,
|
||||
skip = false,
|
||||
pollingInterval = 0,
|
||||
skipPollingIfUnfocused = false,
|
||||
...rest
|
||||
} = {}) {
|
||||
const {
|
||||
initiate
|
||||
} = api.endpoints[endpointName];
|
||||
const dispatch = useDispatch();
|
||||
const subscriptionSelectorsRef = useRef(void 0);
|
||||
if (!subscriptionSelectorsRef.current) {
|
||||
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage(37) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
|
||||
You must add the middleware for RTK-Query to function correctly!`);
|
||||
}
|
||||
}
|
||||
subscriptionSelectorsRef.current = returnedValue;
|
||||
}
|
||||
const stableArg = useStableQueryArgs(skip ? skipToken : arg);
|
||||
const stableSubscriptionOptions = useShallowStableValue({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval,
|
||||
skipPollingIfUnfocused
|
||||
});
|
||||
const initialPageParam = rest.initialPageParam;
|
||||
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
||||
const refetchCachedPages = rest.refetchCachedPages;
|
||||
const stableRefetchCachedPages = useShallowStableValue(refetchCachedPages);
|
||||
const promiseRef = useRef(void 0);
|
||||
let {
|
||||
queryCacheKey,
|
||||
requestId
|
||||
} = promiseRef.current || {};
|
||||
let currentRenderHasSubscription = false;
|
||||
if (queryCacheKey && requestId) {
|
||||
currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
|
||||
}
|
||||
const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
|
||||
usePossiblyImmediateEffect(() => {
|
||||
if (subscriptionRemoved) {
|
||||
promiseRef.current = void 0;
|
||||
}
|
||||
}, [subscriptionRemoved]);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
const lastPromise = promiseRef.current;
|
||||
if (typeof process !== "undefined" && process.env.NODE_ENV === "removeMeOnCompilation") {
|
||||
console.log(subscriptionRemoved);
|
||||
}
|
||||
if (stableArg === skipToken) {
|
||||
lastPromise?.unsubscribe();
|
||||
promiseRef.current = void 0;
|
||||
return;
|
||||
}
|
||||
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
||||
if (!lastPromise || lastPromise.arg !== stableArg) {
|
||||
lastPromise?.unsubscribe();
|
||||
const promise = dispatch(initiate(stableArg, {
|
||||
subscriptionOptions: stableSubscriptionOptions,
|
||||
forceRefetch: refetchOnMountOrArgChange,
|
||||
...isInfiniteQueryDefinition(endpointDefinitions[endpointName]) ? {
|
||||
initialPageParam: stableInitialPageParam,
|
||||
refetchCachedPages: stableRefetchCachedPages
|
||||
} : {}
|
||||
}));
|
||||
promiseRef.current = promise;
|
||||
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
||||
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
|
||||
}
|
||||
}, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, stableRefetchCachedPages, endpointName]);
|
||||
return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
|
||||
}
|
||||
function buildUseQueryState(endpointName, preSelector) {
|
||||
const useQueryState = (arg, {
|
||||
skip = false,
|
||||
selectFromResult
|
||||
} = {}) => {
|
||||
const {
|
||||
select
|
||||
} = api.endpoints[endpointName];
|
||||
const stableArg = useStableQueryArgs(skip ? skipToken : arg);
|
||||
const lastValue = useRef(void 0);
|
||||
const selectDefaultResult = useMemo(() => (
|
||||
// Normally ts-ignores are bad and should be avoided, but we're
|
||||
// already casting this selector to be `Selector<any>` anyway,
|
||||
// so the inconsistencies don't matter here
|
||||
// @ts-ignore
|
||||
createSelector([
|
||||
// @ts-ignore
|
||||
select(stableArg),
|
||||
(_, lastResult) => lastResult,
|
||||
(_) => stableArg
|
||||
], preSelector, {
|
||||
memoizeOptions: {
|
||||
resultEqualityCheck: shallowEqual
|
||||
}
|
||||
})
|
||||
), [select, stableArg]);
|
||||
const querySelector = useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
||||
devModeChecks: {
|
||||
identityFunctionCheck: "never"
|
||||
}
|
||||
}) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
|
||||
const currentState = useSelector((state) => querySelector(state, lastValue.current), shallowEqual);
|
||||
const store = useStore();
|
||||
const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
lastValue.current = newLastValue;
|
||||
}, [newLastValue]);
|
||||
return currentState;
|
||||
};
|
||||
return useQueryState;
|
||||
}
|
||||
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = void 0;
|
||||
};
|
||||
}, [promiseRef]);
|
||||
}
|
||||
function refetchOrErrorIfUnmounted(promiseRef) {
|
||||
if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
|
||||
return promiseRef.current.refetch();
|
||||
}
|
||||
function buildQueryHooks(endpointName) {
|
||||
const useQuerySubscription = (arg, options = {}) => {
|
||||
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
||||
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
||||
return useMemo(() => ({
|
||||
/**
|
||||
* A method to manually refetch data for the query
|
||||
*/
|
||||
refetch: () => refetchOrErrorIfUnmounted(promiseRef)
|
||||
}), [promiseRef]);
|
||||
};
|
||||
const useLazyQuerySubscription = ({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval = 0,
|
||||
skipPollingIfUnfocused = false
|
||||
} = {}) => {
|
||||
const {
|
||||
initiate
|
||||
} = api.endpoints[endpointName];
|
||||
const dispatch = useDispatch();
|
||||
const [arg, setArg] = useState(UNINITIALIZED_VALUE);
|
||||
const promiseRef = useRef(void 0);
|
||||
const stableSubscriptionOptions = useShallowStableValue({
|
||||
refetchOnReconnect,
|
||||
refetchOnFocus,
|
||||
pollingInterval,
|
||||
skipPollingIfUnfocused
|
||||
});
|
||||
usePossiblyImmediateEffect(() => {
|
||||
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
||||
if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
||||
promiseRef.current?.updateSubscriptionOptions(stableSubscriptionOptions);
|
||||
}
|
||||
}, [stableSubscriptionOptions]);
|
||||
const subscriptionOptionsRef = useRef(stableSubscriptionOptions);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
||||
}, [stableSubscriptionOptions]);
|
||||
const trigger = useCallback(function(arg2, preferCacheValue = false) {
|
||||
let promise;
|
||||
batch(() => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = promise = dispatch(initiate(arg2, {
|
||||
subscriptionOptions: subscriptionOptionsRef.current,
|
||||
forceRefetch: !preferCacheValue
|
||||
}));
|
||||
setArg(arg2);
|
||||
});
|
||||
return promise;
|
||||
}, [dispatch, initiate]);
|
||||
const reset = useCallback(() => {
|
||||
if (promiseRef.current?.queryCacheKey) {
|
||||
dispatch(api.internalActions.removeQueryResult({
|
||||
queryCacheKey: promiseRef.current?.queryCacheKey
|
||||
}));
|
||||
}
|
||||
}, [dispatch]);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
};
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
||||
trigger(arg, true);
|
||||
}
|
||||
}, [arg, trigger]);
|
||||
return useMemo(() => [trigger, arg, {
|
||||
reset
|
||||
}], [trigger, arg, reset]);
|
||||
};
|
||||
const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
|
||||
return {
|
||||
useQueryState,
|
||||
useQuerySubscription,
|
||||
useLazyQuerySubscription,
|
||||
useLazyQuery(options) {
|
||||
const [trigger, arg, {
|
||||
reset
|
||||
}] = useLazyQuerySubscription(options);
|
||||
const queryStateResults = useQueryState(arg, {
|
||||
...options,
|
||||
skip: arg === UNINITIALIZED_VALUE
|
||||
});
|
||||
const info = useMemo(() => ({
|
||||
lastArg: arg
|
||||
}), [arg]);
|
||||
return useMemo(() => [trigger, {
|
||||
...queryStateResults,
|
||||
reset
|
||||
}, info], [trigger, queryStateResults, reset, info]);
|
||||
},
|
||||
useQuery(arg, options) {
|
||||
const querySubscriptionResults = useQuerySubscription(arg, options);
|
||||
const queryStateResults = useQueryState(arg, {
|
||||
selectFromResult: arg === skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
||||
...options
|
||||
});
|
||||
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
||||
useDebugValue(debugValue);
|
||||
return useMemo(() => ({
|
||||
...queryStateResults,
|
||||
...querySubscriptionResults
|
||||
}), [queryStateResults, querySubscriptionResults]);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildInfiniteQueryHooks(endpointName) {
|
||||
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
||||
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
||||
const subscriptionOptionsRef = useRef(stableSubscriptionOptions);
|
||||
usePossiblyImmediateEffect(() => {
|
||||
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
||||
}, [stableSubscriptionOptions]);
|
||||
const hookRefetchCachedPages = options.refetchCachedPages;
|
||||
const stableHookRefetchCachedPages = useShallowStableValue(hookRefetchCachedPages);
|
||||
const trigger = useCallback(function(arg2, direction) {
|
||||
let promise;
|
||||
batch(() => {
|
||||
unsubscribePromiseRef(promiseRef);
|
||||
promiseRef.current = promise = dispatch(initiate(arg2, {
|
||||
subscriptionOptions: subscriptionOptionsRef.current,
|
||||
direction
|
||||
}));
|
||||
});
|
||||
return promise;
|
||||
}, [promiseRef, dispatch, initiate]);
|
||||
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
||||
const stableArg = useStableQueryArgs(options.skip ? skipToken : arg);
|
||||
const refetch = useCallback((options2) => {
|
||||
if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage3(38) : "Cannot refetch a query that has not been started yet.");
|
||||
const mergedOptions = {
|
||||
refetchCachedPages: options2?.refetchCachedPages ?? stableHookRefetchCachedPages
|
||||
};
|
||||
return promiseRef.current.refetch(mergedOptions);
|
||||
}, [promiseRef, stableHookRefetchCachedPages]);
|
||||
return useMemo(() => {
|
||||
const fetchNextPage = () => {
|
||||
return trigger(stableArg, "forward");
|
||||
};
|
||||
const fetchPreviousPage = () => {
|
||||
return trigger(stableArg, "backward");
|
||||
};
|
||||
return {
|
||||
trigger,
|
||||
/**
|
||||
* A method to manually refetch data for the query
|
||||
*/
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage
|
||||
};
|
||||
}, [refetch, trigger, stableArg]);
|
||||
};
|
||||
const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
|
||||
return {
|
||||
useInfiniteQueryState,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQuery(arg, options) {
|
||||
const {
|
||||
refetch,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage
|
||||
} = useInfiniteQuerySubscription(arg, options);
|
||||
const queryStateResults = useInfiniteQueryState(arg, {
|
||||
selectFromResult: arg === skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
||||
...options
|
||||
});
|
||||
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
||||
useDebugValue(debugValue);
|
||||
return useMemo(() => ({
|
||||
...queryStateResults,
|
||||
fetchNextPage,
|
||||
fetchPreviousPage,
|
||||
refetch
|
||||
}), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildMutationHook(name) {
|
||||
return ({
|
||||
selectFromResult,
|
||||
fixedCacheKey
|
||||
} = {}) => {
|
||||
const {
|
||||
select,
|
||||
initiate
|
||||
} = api.endpoints[name];
|
||||
const dispatch = useDispatch();
|
||||
const [promise, setPromise] = useState();
|
||||
useEffect(() => () => {
|
||||
if (!promise?.arg.fixedCacheKey) {
|
||||
promise?.reset();
|
||||
}
|
||||
}, [promise]);
|
||||
const triggerMutation = useCallback(function(arg) {
|
||||
const promise2 = dispatch(initiate(arg, {
|
||||
fixedCacheKey
|
||||
}));
|
||||
setPromise(promise2);
|
||||
return promise2;
|
||||
}, [dispatch, initiate, fixedCacheKey]);
|
||||
const {
|
||||
requestId
|
||||
} = promise || {};
|
||||
const selectDefaultResult = useMemo(() => select({
|
||||
fixedCacheKey,
|
||||
requestId: promise?.requestId
|
||||
}), [fixedCacheKey, promise, select]);
|
||||
const mutationSelector = useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
||||
const currentState = useSelector(mutationSelector, shallowEqual);
|
||||
const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : void 0;
|
||||
const reset = useCallback(() => {
|
||||
batch(() => {
|
||||
if (promise) {
|
||||
setPromise(void 0);
|
||||
}
|
||||
if (fixedCacheKey) {
|
||||
dispatch(api.internalActions.removeMutationResult({
|
||||
requestId,
|
||||
fixedCacheKey
|
||||
}));
|
||||
}
|
||||
});
|
||||
}, [dispatch, fixedCacheKey, promise, requestId]);
|
||||
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
||||
useDebugValue(debugValue);
|
||||
const finalState = useMemo(() => ({
|
||||
...currentState,
|
||||
originalArgs,
|
||||
reset
|
||||
}), [currentState, originalArgs, reset]);
|
||||
return useMemo(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// src/query/react/module.ts
|
||||
var reactHooksModuleName = /* @__PURE__ */ Symbol();
|
||||
var reactHooksModule = ({
|
||||
batch = rrBatch,
|
||||
hooks = {
|
||||
useDispatch: rrUseDispatch,
|
||||
useSelector: rrUseSelector,
|
||||
useStore: rrUseStore
|
||||
},
|
||||
createSelector = _createSelector,
|
||||
unstable__sideEffectsInRender = false,
|
||||
...rest
|
||||
} = {}) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
const hookNames = ["useDispatch", "useSelector", "useStore"];
|
||||
let warned = false;
|
||||
for (const hookName of hookNames) {
|
||||
if (countObjectKeys(rest) > 0) {
|
||||
if (rest[hookName]) {
|
||||
if (!warned) {
|
||||
console.warn("As of RTK 2.0, the hooks now need to be specified as one object, provided under a `hooks` key:\n`reactHooksModule({ hooks: { useDispatch, useSelector, useStore } })`");
|
||||
warned = true;
|
||||
}
|
||||
}
|
||||
hooks[hookName] = rest[hookName];
|
||||
}
|
||||
if (typeof hooks[hookName] !== "function") {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage4(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(", ")}.
|
||||
Hook ${hookName} was either not provided or not a function.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
name: reactHooksModuleName,
|
||||
init(api, {
|
||||
serializeQueryArgs
|
||||
}, context) {
|
||||
const anyApi = api;
|
||||
const {
|
||||
buildQueryHooks,
|
||||
buildInfiniteQueryHooks,
|
||||
buildMutationHook,
|
||||
usePrefetch
|
||||
} = buildHooks({
|
||||
api,
|
||||
moduleOptions: {
|
||||
batch,
|
||||
hooks,
|
||||
unstable__sideEffectsInRender,
|
||||
createSelector
|
||||
},
|
||||
serializeQueryArgs,
|
||||
context
|
||||
});
|
||||
safeAssign(anyApi, {
|
||||
usePrefetch
|
||||
});
|
||||
safeAssign(context, {
|
||||
batch
|
||||
});
|
||||
return {
|
||||
injectEndpoint(endpointName, definition) {
|
||||
if (isQueryDefinition(definition)) {
|
||||
const {
|
||||
useQuery,
|
||||
useLazyQuery,
|
||||
useLazyQuerySubscription,
|
||||
useQueryState,
|
||||
useQuerySubscription
|
||||
} = buildQueryHooks(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useQuery,
|
||||
useLazyQuery,
|
||||
useLazyQuerySubscription,
|
||||
useQueryState,
|
||||
useQuerySubscription
|
||||
});
|
||||
api[`use${capitalize(endpointName)}Query`] = useQuery;
|
||||
api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
|
||||
}
|
||||
if (isMutationDefinition(definition)) {
|
||||
const useMutation = buildMutationHook(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useMutation
|
||||
});
|
||||
api[`use${capitalize(endpointName)}Mutation`] = useMutation;
|
||||
} else if (isInfiniteQueryDefinition(definition)) {
|
||||
const {
|
||||
useInfiniteQuery,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQueryState
|
||||
} = buildInfiniteQueryHooks(endpointName);
|
||||
safeAssign(anyApi.endpoints[endpointName], {
|
||||
useInfiniteQuery,
|
||||
useInfiniteQuerySubscription,
|
||||
useInfiniteQueryState
|
||||
});
|
||||
api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// src/query/react/index.ts
|
||||
export * from "@reduxjs/toolkit/query";
|
||||
|
||||
// src/query/react/ApiProvider.tsx
|
||||
import { configureStore, formatProdErrorMessage as _formatProdErrorMessage5 } from "@reduxjs/toolkit";
|
||||
import * as React from "react";
|
||||
function ApiProvider(props) {
|
||||
const context = props.context || ReactReduxContext;
|
||||
const existingContext = useContext(context);
|
||||
if (existingContext) {
|
||||
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage5(35) : "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.");
|
||||
}
|
||||
const [store] = React.useState(() => configureStore({
|
||||
reducer: {
|
||||
[props.api.reducerPath]: props.api.reducer
|
||||
},
|
||||
middleware: (gDM) => gDM().concat(props.api.middleware)
|
||||
}));
|
||||
useEffect(() => props.setupListeners === false ? void 0 : setupListeners(store.dispatch, props.setupListeners), [props.setupListeners, store.dispatch]);
|
||||
return /* @__PURE__ */ React.createElement(Provider, { store, context }, props.children);
|
||||
}
|
||||
|
||||
// src/query/react/index.ts
|
||||
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
||||
export {
|
||||
ApiProvider,
|
||||
UNINITIALIZED_VALUE,
|
||||
createApi,
|
||||
reactHooksModule,
|
||||
reactHooksModuleName
|
||||
};
|
||||
//# sourceMappingURL=rtk-query-react.modern.mjs.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs
generated
vendored
Normal file
2
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3116
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js
generated
vendored
Normal file
3116
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3047
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs
generated
vendored
Normal file
3047
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/index.js
generated
vendored
Normal file
6
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./redux-toolkit-react.production.min.cjs')
|
||||
} else {
|
||||
module.exports = require('./redux-toolkit-react.development.cjs')
|
||||
}
|
||||
55
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs
generated
vendored
Normal file
55
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/react/index.ts
|
||||
var react_exports = {};
|
||||
__export(react_exports, {
|
||||
createDynamicMiddleware: () => createDynamicMiddleware
|
||||
});
|
||||
module.exports = __toCommonJS(react_exports);
|
||||
__reExport(react_exports, require("@reduxjs/toolkit"), module.exports);
|
||||
|
||||
// src/dynamicMiddleware/react/index.ts
|
||||
var import_toolkit = require("@reduxjs/toolkit");
|
||||
var import_react_redux = require("react-redux");
|
||||
var createDynamicMiddleware = () => {
|
||||
const instance = (0, import_toolkit.createDynamicMiddleware)();
|
||||
const createDispatchWithMiddlewareHookFactory = (context = import_react_redux.ReactReduxContext) => {
|
||||
const useDispatch = context === import_react_redux.ReactReduxContext ? import_react_redux.useDispatch : (0, import_react_redux.createDispatchHook)(context);
|
||||
function createDispatchWithMiddlewareHook2(...middlewares) {
|
||||
instance.addMiddleware(...middlewares);
|
||||
return useDispatch;
|
||||
}
|
||||
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
||||
return createDispatchWithMiddlewareHook2;
|
||||
};
|
||||
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
||||
return {
|
||||
...instance,
|
||||
createDispatchWithMiddlewareHookFactory,
|
||||
createDispatchWithMiddlewareHook
|
||||
};
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
createDynamicMiddleware,
|
||||
...require("@reduxjs/toolkit")
|
||||
});
|
||||
//# sourceMappingURL=redux-toolkit-react.development.cjs.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/react/index.ts","../../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';\nexport type { CreateDispatchWithMiddlewareHook } from '../dynamicMiddleware/react/index';","import type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { Context } from 'react';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from 'react-redux';\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux';\nexport type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;\nexport type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {\n <Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;\n withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;\n};\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;\ntype ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;\n};\nexport const createDynamicMiddleware = <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>();\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n function createDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<State, DispatchType>;\n };\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAc,6BAHd;;;ACCA,qBAA+C;AAG/C,yBAAyF;AAYlF,IAAM,0BAA0B,MAAgJ;AACrL,QAAM,eAAW,eAAAA,yBAAyB;AAC1C,QAAM,0CAA0C,CAEhD,UAA2F,yCAAsB;AAC/G,UAAM,cAAc,YAAY,uCAAoB,mBAAAC,kBAAqB,uCAAmB,OAAO;AACnG,aAASC,qCAAgG,aAA0B;AACjI,eAAS,cAAc,GAAG,WAAW;AACrC,aAAO;AAAA,IACT;AACA,IAAAA,kCAAiC,YAAY,MAAMA;AACnD,WAAOA;AAAA,EACT;AACA,QAAM,mCAAmC,wCAAwC;AACjF,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":["cDM","useDefaultDispatch","createDispatchWithMiddlewareHook"]}
|
||||
2
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs
generated
vendored
Normal file
2
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";var s=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},d=(t,e,a,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of y(e))!M.call(t,i)&&i!==a&&s(t,i,{get:()=>e[i],enumerable:!(n=w(e,i))||n.enumerable});return t},r=(t,e,a)=>(d(t,e,"default"),a&&d(a,e,"default"));var m=t=>d(s({},"__esModule",{value:!0}),t);var o={};x(o,{createDynamicMiddleware:()=>D});module.exports=m(o);r(o,require("@reduxjs/toolkit"),module.exports);var h=require("@reduxjs/toolkit"),c=require("react-redux"),D=()=>{let t=(0,h.createDynamicMiddleware)(),e=(n=c.ReactReduxContext)=>{let i=n===c.ReactReduxContext?c.useDispatch:(0,c.createDispatchHook)(n);function p(...l){return t.addMiddleware(...l),i}return p.withTypes=()=>p,p},a=e();return{...t,createDispatchWithMiddlewareHookFactory:e,createDispatchWithMiddlewareHook:a}};0&&(module.exports={createDynamicMiddleware,...require("@reduxjs/toolkit")});
|
||||
//# sourceMappingURL=redux-toolkit-react.production.min.cjs.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/react/index.ts","../../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';\nexport type { CreateDispatchWithMiddlewareHook } from '../dynamicMiddleware/react/index';","import type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { Context } from 'react';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from 'react-redux';\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux';\nexport type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;\nexport type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {\n <Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;\n withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;\n};\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;\ntype ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;\n};\nexport const createDynamicMiddleware = <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>();\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n function createDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<State, DispatchType>;\n };\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":"2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAGAI,EAAAJ,EAAc,4BAHd,gBCCA,IAAAK,EAA+C,4BAG/CC,EAAyF,uBAY5EC,EAA0B,IAAgJ,CACrL,IAAMC,KAAW,EAAAC,yBAAyB,EACpCC,EAA0C,CAEhDC,EAA2F,sBAAsB,CAC/G,IAAMC,EAAcD,IAAY,oBAAoB,EAAAE,eAAqB,sBAAmBF,CAAO,EACnG,SAASG,KAAgGC,EAA0B,CACjI,OAAAP,EAAS,cAAc,GAAGO,CAAW,EAC9BH,CACT,CACA,OAAAE,EAAiC,UAAY,IAAMA,EAC5CA,CACT,EACMA,EAAmCJ,EAAwC,EACjF,MAAO,CACL,GAAGF,EACH,wCAAAE,EACA,iCAAAI,CACF,CACF","names":["react_exports","__export","createDynamicMiddleware","__toCommonJS","__reExport","import_toolkit","import_react_redux","createDynamicMiddleware","instance","cDM","createDispatchWithMiddlewareHookFactory","context","useDispatch","useDefaultDispatch","createDispatchWithMiddlewareHook","middlewares"]}
|
||||
22
frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.mts
generated
vendored
Normal file
22
frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { DynamicMiddlewareInstance, TSHelpersExtractDispatchExtensions, MiddlewareApiConfig, GetState, GetDispatch } from '@reduxjs/toolkit';
|
||||
export * from '@reduxjs/toolkit';
|
||||
import { Context } from 'react';
|
||||
import { ReactReduxContextValue } from 'react-redux';
|
||||
import { Dispatch, UnknownAction, Action, Middleware } from 'redux';
|
||||
|
||||
type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
||||
type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
||||
<Middlewares extends [
|
||||
Middleware<any, State, DispatchType>,
|
||||
...Middleware<any, State, DispatchType>[]
|
||||
]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
||||
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
||||
};
|
||||
type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
||||
type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
||||
createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
||||
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
||||
};
|
||||
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
||||
|
||||
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
||||
22
frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.ts
generated
vendored
Normal file
22
frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { DynamicMiddlewareInstance, TSHelpersExtractDispatchExtensions, MiddlewareApiConfig, GetState, GetDispatch } from '@reduxjs/toolkit';
|
||||
export * from '@reduxjs/toolkit';
|
||||
import { Context } from 'react';
|
||||
import { ReactReduxContextValue } from 'react-redux';
|
||||
import { Dispatch, UnknownAction, Action, Middleware } from 'redux';
|
||||
|
||||
type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
||||
type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
||||
<Middlewares extends [
|
||||
Middleware<any, State, DispatchType>,
|
||||
...Middleware<any, State, DispatchType>[]
|
||||
]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
||||
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
||||
};
|
||||
type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
||||
type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
||||
createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
||||
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
||||
};
|
||||
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
||||
|
||||
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
||||
2
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs
generated
vendored
Normal file
2
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export*from"@reduxjs/toolkit";import{createDynamicMiddleware as p}from"@reduxjs/toolkit";import{createDispatchHook as d,ReactReduxContext as c,useDispatch as s}from"react-redux";var h=()=>{let t=p(),a=(i=c)=>{let o=i===c?s:d(i);function e(...r){return t.addMiddleware(...r),o}return e.withTypes=()=>e,e},n=a();return{...t,createDispatchWithMiddlewareHookFactory:a,createDispatchWithMiddlewareHook:n}};export{h as createDynamicMiddleware};
|
||||
//# sourceMappingURL=redux-toolkit-react.browser.mjs.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/react/index.ts","../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';\nexport type { CreateDispatchWithMiddlewareHook } from '../dynamicMiddleware/react/index';","import type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { Context } from 'react';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from 'react-redux';\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux';\nexport type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;\nexport type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {\n <Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;\n withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;\n};\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;\ntype ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;\n};\nexport const createDynamicMiddleware = <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>();\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n function createDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<State, DispatchType>;\n };\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":"AAGA,WAAc,mBCFd,OAAS,2BAA2BA,MAAW,mBAG/C,OAAS,sBAAAC,EAAoB,qBAAAC,EAAmB,eAAeC,MAA0B,cAYlF,IAAMC,EAA0B,IAAgJ,CACrL,IAAMC,EAAWL,EAAyB,EACpCM,EAA0C,CAEhDC,EAA2FL,IAAsB,CAC/G,IAAMM,EAAcD,IAAYL,EAAoBC,EAAqBF,EAAmBM,CAAO,EACnG,SAASE,KAAgGC,EAA0B,CACjI,OAAAL,EAAS,cAAc,GAAGK,CAAW,EAC9BF,CACT,CACA,OAAAC,EAAiC,UAAY,IAAMA,EAC5CA,CACT,EACMA,EAAmCH,EAAwC,EACjF,MAAO,CACL,GAAGD,EACH,wCAAAC,EACA,iCAAAG,CACF,CACF","names":["cDM","createDispatchHook","ReactReduxContext","useDefaultDispatch","createDynamicMiddleware","instance","createDispatchWithMiddlewareHookFactory","context","useDispatch","createDispatchWithMiddlewareHook","middlewares"]}
|
||||
47
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js
generated
vendored
Normal file
47
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
|
||||
// src/react/index.ts
|
||||
export * from "@reduxjs/toolkit";
|
||||
|
||||
// src/dynamicMiddleware/react/index.ts
|
||||
import { createDynamicMiddleware as cDM } from "@reduxjs/toolkit";
|
||||
import { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from "react-redux";
|
||||
var createDynamicMiddleware = () => {
|
||||
const instance = cDM();
|
||||
const createDispatchWithMiddlewareHookFactory = (context = ReactReduxContext) => {
|
||||
const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);
|
||||
function createDispatchWithMiddlewareHook2(...middlewares) {
|
||||
instance.addMiddleware(...middlewares);
|
||||
return useDispatch;
|
||||
}
|
||||
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
||||
return createDispatchWithMiddlewareHook2;
|
||||
};
|
||||
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
||||
return __spreadProps(__spreadValues({}, instance), {
|
||||
createDispatchWithMiddlewareHookFactory,
|
||||
createDispatchWithMiddlewareHook
|
||||
});
|
||||
};
|
||||
export {
|
||||
createDynamicMiddleware
|
||||
};
|
||||
//# sourceMappingURL=redux-toolkit-react.legacy-esm.js.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/react/index.ts","../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';\nexport type { CreateDispatchWithMiddlewareHook } from '../dynamicMiddleware/react/index';","import type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { Context } from 'react';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from 'react-redux';\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux';\nexport type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;\nexport type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {\n <Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;\n withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;\n};\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;\ntype ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;\n};\nexport const createDynamicMiddleware = <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>();\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n function createDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<State, DispatchType>;\n };\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,cAAc;;;ACFd,SAAS,2BAA2B,WAAW;AAG/C,SAAS,oBAAoB,mBAAmB,eAAe,0BAA0B;AAYlF,IAAM,0BAA0B,MAAgJ;AACrL,QAAM,WAAW,IAAyB;AAC1C,QAAM,0CAA0C,CAEhD,UAA2F,sBAAsB;AAC/G,UAAM,cAAc,YAAY,oBAAoB,qBAAqB,mBAAmB,OAAO;AACnG,aAASA,qCAAgG,aAA0B;AACjI,eAAS,cAAc,GAAG,WAAW;AACrC,aAAO;AAAA,IACT;AACA,IAAAA,kCAAiC,YAAY,MAAMA;AACnD,WAAOA;AAAA,EACT;AACA,QAAM,mCAAmC,wCAAwC;AACjF,SAAO,iCACF,WADE;AAAA,IAEL;AAAA,IACA;AAAA,EACF;AACF;","names":["createDispatchWithMiddlewareHook"]}
|
||||
28
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs
generated
vendored
Normal file
28
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// src/react/index.ts
|
||||
export * from "@reduxjs/toolkit";
|
||||
|
||||
// src/dynamicMiddleware/react/index.ts
|
||||
import { createDynamicMiddleware as cDM } from "@reduxjs/toolkit";
|
||||
import { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from "react-redux";
|
||||
var createDynamicMiddleware = () => {
|
||||
const instance = cDM();
|
||||
const createDispatchWithMiddlewareHookFactory = (context = ReactReduxContext) => {
|
||||
const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);
|
||||
function createDispatchWithMiddlewareHook2(...middlewares) {
|
||||
instance.addMiddleware(...middlewares);
|
||||
return useDispatch;
|
||||
}
|
||||
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
||||
return createDispatchWithMiddlewareHook2;
|
||||
};
|
||||
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
||||
return {
|
||||
...instance,
|
||||
createDispatchWithMiddlewareHookFactory,
|
||||
createDispatchWithMiddlewareHook
|
||||
};
|
||||
};
|
||||
export {
|
||||
createDynamicMiddleware
|
||||
};
|
||||
//# sourceMappingURL=redux-toolkit-react.modern.mjs.map
|
||||
1
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/react/index.ts","../../src/dynamicMiddleware/react/index.ts"],"sourcesContent":["// This must remain here so that the `mangleErrors.cjs` build script\n// does not have to import this into each source file it rewrites.\nimport { formatProdErrorMessage } from '@reduxjs/toolkit';\nexport * from '@reduxjs/toolkit';\nexport { createDynamicMiddleware } from '../dynamicMiddleware/react';\nexport type { CreateDispatchWithMiddlewareHook } from '../dynamicMiddleware/react/index';","import type { DynamicMiddlewareInstance, GetDispatch, GetState, MiddlewareApiConfig, TSHelpersExtractDispatchExtensions } from '@reduxjs/toolkit';\nimport { createDynamicMiddleware as cDM } from '@reduxjs/toolkit';\nimport type { Context } from 'react';\nimport type { ReactReduxContextValue } from 'react-redux';\nimport { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from 'react-redux';\nimport type { Action, Dispatch, Middleware, UnknownAction } from 'redux';\nexport type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;\nexport type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {\n <Middlewares extends [Middleware<any, State, DispatchType>, ...Middleware<any, State, DispatchType>[]]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;\n withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;\n};\ntype ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;\ntype ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {\n createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;\n createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;\n};\nexport const createDynamicMiddleware = <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>(): ReactDynamicMiddlewareInstance<State, DispatchType> => {\n const instance = cDM<State, DispatchType>();\n const createDispatchWithMiddlewareHookFactory = (\n // @ts-ignore\n context: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null> = ReactReduxContext) => {\n const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);\n function createDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[]>(...middlewares: Middlewares) {\n instance.addMiddleware(...middlewares);\n return useDispatch;\n }\n createDispatchWithMiddlewareHook.withTypes = () => createDispatchWithMiddlewareHook;\n return createDispatchWithMiddlewareHook as CreateDispatchWithMiddlewareHook<State, DispatchType>;\n };\n const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();\n return {\n ...instance,\n createDispatchWithMiddlewareHookFactory,\n createDispatchWithMiddlewareHook\n };\n};"],"mappings":";AAGA,cAAc;;;ACFd,SAAS,2BAA2B,WAAW;AAG/C,SAAS,oBAAoB,mBAAmB,eAAe,0BAA0B;AAYlF,IAAM,0BAA0B,MAAgJ;AACrL,QAAM,WAAW,IAAyB;AAC1C,QAAM,0CAA0C,CAEhD,UAA2F,sBAAsB;AAC/G,UAAM,cAAc,YAAY,oBAAoB,qBAAqB,mBAAmB,OAAO;AACnG,aAASA,qCAAgG,aAA0B;AACjI,eAAS,cAAc,GAAG,WAAW;AACrC,aAAO;AAAA,IACT;AACA,IAAAA,kCAAiC,YAAY,MAAMA;AACnD,WAAOA;AAAA,EACT;AACA,QAAM,mCAAmC,wCAAwC;AACjF,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":["createDispatchWithMiddlewareHook"]}
|
||||
3
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs
generated
vendored
Normal file
3
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2337
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.legacy-esm.js
generated
vendored
Normal file
2337
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.legacy-esm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.legacy-esm.js.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.legacy-esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2311
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
generated
vendored
Normal file
2311
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16
frontend/node_modules/@reduxjs/toolkit/dist/uncheckedindexed.ts
generated
vendored
Normal file
16
frontend/node_modules/@reduxjs/toolkit/dist/uncheckedindexed.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// inlined from https://github.com/EskiMojo14/uncheckedindexed
|
||||
// relies on remaining as a TS file, not .d.ts
|
||||
type IfMaybeUndefined<T, True, False> = [undefined] extends [T] ? True : False
|
||||
|
||||
const testAccess = ({} as Record<string, 0>)['a']
|
||||
|
||||
export type IfUncheckedIndexedAccess<True, False> = IfMaybeUndefined<
|
||||
typeof testAccess,
|
||||
True,
|
||||
False
|
||||
>
|
||||
|
||||
export type UncheckedIndexedAccess<T> = IfUncheckedIndexedAccess<
|
||||
T | undefined,
|
||||
T
|
||||
>
|
||||
Reference in New Issue
Block a user