UNPKG

@reduxjs/toolkit

Version:

The official, opinionated, batteries-included toolset for efficient Redux development

1 lines 136 kB
{"version":3,"sources":["../../../src/query/react/index.ts","../../../src/query/react/module.ts","../../../src/query/utils/capitalize.ts","../../../src/query/endpointDefinitions.ts","../../../src/query/tsHelpers.ts","../../../src/query/react/buildHooks.ts","../../../src/query/react/constants.ts","../../../src/query/react/useSerializedStableValue.ts","../../../src/query/react/useShallowStableValue.ts","../../../src/query/react/ApiProvider.tsx"],"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';\nimport { buildCreateApi, coreModule } from '@reduxjs/toolkit/query';\nimport { reactHooksModule, reactHooksModuleName } from './module';\nexport * from '@reduxjs/toolkit/query';\nexport { ApiProvider } from './ApiProvider';\nconst createApi = /* @__PURE__ */buildCreateApi(coreModule(), reactHooksModule());\nexport type { TypedUseMutationResult, TypedUseQueryHookResult, TypedUseQueryStateResult, TypedUseQuerySubscriptionResult, TypedLazyQueryTrigger, TypedUseLazyQuery, TypedUseMutation, TypedMutationTrigger, TypedQueryStateSelector, TypedUseQueryState, TypedUseQuery, TypedUseQuerySubscription, TypedUseLazyQuerySubscription, TypedUseQueryStateOptions, TypedUseLazyQueryStateResult, TypedUseInfiniteQuery, TypedUseInfiniteQueryHookResult, TypedUseInfiniteQueryStateResult, TypedUseInfiniteQuerySubscriptionResult, TypedUseInfiniteQueryStateOptions, TypedInfiniteQueryStateSelector, TypedUseInfiniteQuerySubscription, TypedUseInfiniteQueryState, TypedLazyInfiniteQueryTrigger } from './buildHooks';\nexport { UNINITIALIZED_VALUE } from './constants';\nexport { createApi, reactHooksModule, reactHooksModuleName };","import { formatProdErrorMessage as _formatProdErrorMessage } from \"@reduxjs/toolkit\";\nimport type { Api, BaseQueryFn, EndpointDefinitions, InfiniteQueryDefinition, Module, MutationDefinition, PrefetchOptions, QueryArgFrom, QueryDefinition, QueryKeys } from '@reduxjs/toolkit/query';\nimport { batch as rrBatch, useDispatch as rrUseDispatch, useSelector as rrUseSelector, useStore as rrUseStore } from 'react-redux';\nimport { createSelector as _createSelector } from 'reselect';\nimport { isInfiniteQueryDefinition, isMutationDefinition, isQueryDefinition } from '../endpointDefinitions';\nimport { safeAssign } from '../tsHelpers';\nimport { capitalize, countObjectKeys } from '../utils';\nimport type { InfiniteQueryHooks, MutationHooks, QueryHooks } from './buildHooks';\nimport { buildHooks } from './buildHooks';\nimport type { HooksWithUniqueNames } from './namedHooks';\nexport const reactHooksModuleName = /* @__PURE__ */Symbol();\nexport type ReactHooksModule = typeof reactHooksModuleName;\ndeclare module '@reduxjs/toolkit/query' {\n export interface ApiModules<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ReducerPath extends string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TagTypes extends string> {\n [reactHooksModuleName]: {\n /**\n * Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.\n */\n 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 };\n /**\n * A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.\n */\n usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;\n } & HooksWithUniqueNames<Definitions>;\n }\n}\ntype RR = typeof import('react-redux');\nexport interface ReactHooksModuleOptions {\n /**\n * The hooks from React Redux to be used\n */\n hooks?: {\n /**\n * The version of the `useDispatch` hook to be used\n */\n useDispatch: RR['useDispatch'];\n /**\n * The version of the `useSelector` hook to be used\n */\n useSelector: RR['useSelector'];\n /**\n * The version of the `useStore` hook to be used\n */\n useStore: RR['useStore'];\n };\n /**\n * The version of the `batchedUpdates` function to be used\n */\n batch?: RR['batch'];\n /**\n * Enables performing asynchronous tasks immediately within a render.\n *\n * @example\n *\n * ```ts\n * import {\n * buildCreateApi,\n * coreModule,\n * reactHooksModule\n * } from '@reduxjs/toolkit/query/react'\n *\n * const createApi = buildCreateApi(\n * coreModule(),\n * reactHooksModule({ unstable__sideEffectsInRender: true })\n * )\n * ```\n */\n unstable__sideEffectsInRender?: boolean;\n /**\n * A selector creator (usually from `reselect`, or matching the same signature)\n */\n createSelector?: typeof _createSelector;\n}\n\n/**\n * Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.\n *\n * @example\n * ```ts\n * const MyContext = React.createContext<ReactReduxContextValue | null>(null);\n * const customCreateApi = buildCreateApi(\n * coreModule(),\n * reactHooksModule({\n * hooks: {\n * useDispatch: createDispatchHook(MyContext),\n * useSelector: createSelectorHook(MyContext),\n * useStore: createStoreHook(MyContext)\n * }\n * })\n * );\n * ```\n *\n * @returns A module for use with `buildCreateApi`\n */\nexport const reactHooksModule = ({\n batch = rrBatch,\n hooks = {\n useDispatch: rrUseDispatch,\n useSelector: rrUseSelector,\n useStore: rrUseStore\n },\n createSelector = _createSelector,\n unstable__sideEffectsInRender = false,\n ...rest\n}: ReactHooksModuleOptions = {}): Module<ReactHooksModule> => {\n if (process.env.NODE_ENV !== 'production') {\n const hookNames = ['useDispatch', 'useSelector', 'useStore'] as const;\n let warned = false;\n for (const hookName of hookNames) {\n // warn for old hook options\n if (countObjectKeys(rest) > 0) {\n if ((rest as Partial<typeof hooks>)[hookName]) {\n if (!warned) {\n 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 } })`');\n warned = true;\n }\n }\n // migrate\n // @ts-ignore\n hooks[hookName] = rest[hookName];\n }\n // then make sure we have them all\n if (typeof hooks[hookName] !== 'function') {\n throw new Error(process.env.NODE_ENV === \"production\" ? _formatProdErrorMessage(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(', ')}.\\nHook ${hookName} was either not provided or not a function.`);\n }\n }\n }\n return {\n name: reactHooksModuleName,\n init(api, {\n serializeQueryArgs\n }, context) {\n const anyApi = api as any as Api<any, Record<string, any>, any, any, ReactHooksModule>;\n const {\n buildQueryHooks,\n buildInfiniteQueryHooks,\n buildMutationHook,\n usePrefetch\n } = buildHooks({\n api,\n moduleOptions: {\n batch,\n hooks,\n unstable__sideEffectsInRender,\n createSelector\n },\n serializeQueryArgs,\n context\n });\n safeAssign(anyApi, {\n usePrefetch\n });\n safeAssign(context, {\n batch\n });\n return {\n injectEndpoint(endpointName, definition) {\n if (isQueryDefinition(definition)) {\n const {\n useQuery,\n useLazyQuery,\n useLazyQuerySubscription,\n useQueryState,\n useQuerySubscription\n } = buildQueryHooks(endpointName);\n safeAssign(anyApi.endpoints[endpointName], {\n useQuery,\n useLazyQuery,\n useLazyQuerySubscription,\n useQueryState,\n useQuerySubscription\n });\n (api as any)[`use${capitalize(endpointName)}Query`] = useQuery;\n (api as any)[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;\n }\n if (isMutationDefinition(definition)) {\n const useMutation = buildMutationHook(endpointName);\n safeAssign(anyApi.endpoints[endpointName], {\n useMutation\n });\n (api as any)[`use${capitalize(endpointName)}Mutation`] = useMutation;\n } else if (isInfiniteQueryDefinition(definition)) {\n const {\n useInfiniteQuery,\n useInfiniteQuerySubscription,\n useInfiniteQueryState\n } = buildInfiniteQueryHooks(endpointName);\n safeAssign(anyApi.endpoints[endpointName], {\n useInfiniteQuery,\n useInfiniteQuerySubscription,\n useInfiniteQueryState\n });\n (api as any)[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;\n }\n }\n };\n }\n };\n};","export function capitalize(str: string) {\n return str.replace(str[0], str[0].toUpperCase());\n}","import type { Api } from '@reduxjs/toolkit/query';\nimport type { BaseQueryApi, BaseQueryArg, BaseQueryError, BaseQueryExtraOptions, BaseQueryFn, BaseQueryMeta, BaseQueryResult, QueryReturnValue } from './baseQueryTypes';\nimport type { CacheCollectionQueryExtraOptions } from './core/buildMiddleware/cacheCollection';\nimport type { CacheLifecycleInfiniteQueryExtraOptions, CacheLifecycleMutationExtraOptions, CacheLifecycleQueryExtraOptions } from './core/buildMiddleware/cacheLifecycle';\nimport type { QueryLifecycleInfiniteQueryExtraOptions, QueryLifecycleMutationExtraOptions, QueryLifecycleQueryExtraOptions } from './core/buildMiddleware/queryLifecycle';\nimport type { InfiniteData, InfiniteQueryConfigOptions, QuerySubState, RootState } from './core/index';\nimport type { SerializeQueryArgs } from './defaultSerializeQueryArgs';\nimport type { NEVER } from './fakeBaseQuery';\nimport type { CastAny, HasRequiredProps, MaybePromise, NonUndefined, OmitFromUnion, UnwrapPromise } from './tsHelpers';\nimport { isNotNullish } from './utils';\nconst resultType = /* @__PURE__ */Symbol();\nconst baseQuery = /* @__PURE__ */Symbol();\ntype EndpointDefinitionWithQuery<QueryArg, BaseQuery extends BaseQueryFn, ResultType> = {\n /**\n * `query` can be a function that returns either a `string` or an `object` which is passed to your `baseQuery`. If you are using [fetchBaseQuery](./fetchBaseQuery), this can return either a `string` or an `object` of properties in `FetchArgs`. If you use your own custom [`baseQuery`](../../rtk-query/usage/customizing-queries), you can customize this behavior to your liking.\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"query example\"\n *\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n * type PostsResponse = Post[]\n *\n * const api = createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * tagTypes: ['Post'],\n * endpoints: (build) => ({\n * getPosts: build.query<PostsResponse, void>({\n * // highlight-start\n * query: () => 'posts',\n * // highlight-end\n * }),\n * addPost: build.mutation<Post, Partial<Post>>({\n * // highlight-start\n * query: (body) => ({\n * url: `posts`,\n * method: 'POST',\n * body,\n * }),\n * // highlight-end\n * invalidatesTags: [{ type: 'Post', id: 'LIST' }],\n * }),\n * })\n * })\n * ```\n */\n query(arg: QueryArg): BaseQueryArg<BaseQuery>;\n queryFn?: never;\n /**\n * A function to manipulate the data returned by a query or mutation.\n */\n transformResponse?(baseQueryReturnValue: BaseQueryResult<BaseQuery>, meta: BaseQueryMeta<BaseQuery>, arg: QueryArg): ResultType | Promise<ResultType>;\n /**\n * A function to manipulate the data returned by a failed query or mutation.\n */\n transformErrorResponse?(baseQueryReturnValue: BaseQueryError<BaseQuery>, meta: BaseQueryMeta<BaseQuery>, arg: QueryArg): unknown;\n /**\n * Defaults to `true`.\n *\n * Most apps should leave this setting on. The only time it can be a performance issue\n * is if an API returns extremely large amounts of data (e.g. 10,000 rows per request) and\n * you're unable to paginate it.\n *\n * For details of how this works, please see the below. When it is set to `false`,\n * every request will cause subscribed components to rerender, even when the data has not changed.\n *\n * @see https://redux-toolkit.js.org/api/other-exports#copywithstructuralsharing\n */\n structuralSharing?: boolean;\n};\ntype EndpointDefinitionWithQueryFn<QueryArg, BaseQuery extends BaseQueryFn, ResultType> = {\n /**\n * Can be used in place of `query` as an inline function that bypasses `baseQuery` completely for the endpoint.\n *\n * @example\n * ```ts\n * // codeblock-meta title=\"Basic queryFn example\"\n *\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n * type PostsResponse = Post[]\n *\n * const api = createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * endpoints: (build) => ({\n * getPosts: build.query<PostsResponse, void>({\n * query: () => 'posts',\n * }),\n * flipCoin: build.query<'heads' | 'tails', void>({\n * // highlight-start\n * queryFn(arg, queryApi, extraOptions, baseQuery) {\n * const randomVal = Math.random()\n * if (randomVal < 0.45) {\n * return { data: 'heads' }\n * }\n * if (randomVal < 0.9) {\n * return { data: 'tails' }\n * }\n * return { error: { status: 500, statusText: 'Internal Server Error', data: \"Coin landed on its edge!\" } }\n * }\n * // highlight-end\n * })\n * })\n * })\n * ```\n */\n queryFn(arg: QueryArg, api: BaseQueryApi, extraOptions: BaseQueryExtraOptions<BaseQuery>, baseQuery: (arg: Parameters<BaseQuery>[0]) => ReturnType<BaseQuery>): MaybePromise<QueryReturnValue<ResultType, BaseQueryError<BaseQuery>, BaseQueryMeta<BaseQuery>>>;\n query?: never;\n transformResponse?: never;\n transformErrorResponse?: never;\n /**\n * Defaults to `true`.\n *\n * Most apps should leave this setting on. The only time it can be a performance issue\n * is if an API returns extremely large amounts of data (e.g. 10,000 rows per request) and\n * you're unable to paginate it.\n *\n * For details of how this works, please see the below. When it is set to `false`,\n * every request will cause subscribed components to rerender, even when the data has not changed.\n *\n * @see https://redux-toolkit.js.org/api/other-exports#copywithstructuralsharing\n */\n structuralSharing?: boolean;\n};\ntype BaseEndpointTypes<QueryArg, BaseQuery extends BaseQueryFn, ResultType> = {\n QueryArg: QueryArg;\n BaseQuery: BaseQuery;\n ResultType: ResultType;\n};\nexport type BaseEndpointDefinition<QueryArg, BaseQuery extends BaseQueryFn, ResultType> = (([CastAny<BaseQueryResult<BaseQuery>, {}>] extends [NEVER] ? never : EndpointDefinitionWithQuery<QueryArg, BaseQuery, ResultType>) | EndpointDefinitionWithQueryFn<QueryArg, BaseQuery, ResultType>) & {\n /* phantom type */\n [resultType]?: ResultType;\n /* phantom type */\n [baseQuery]?: BaseQuery;\n} & HasRequiredProps<BaseQueryExtraOptions<BaseQuery>, {\n extraOptions: BaseQueryExtraOptions<BaseQuery>;\n}, {\n extraOptions?: BaseQueryExtraOptions<BaseQuery>;\n}>;\nexport enum DefinitionType {\n query = 'query',\n mutation = 'mutation',\n infinitequery = 'infinitequery',\n}\nexport type GetResultDescriptionFn<TagTypes extends string, ResultType, QueryArg, ErrorType, MetaType> = (result: ResultType | undefined, error: ErrorType | undefined, arg: QueryArg, meta: MetaType) => ReadonlyArray<TagDescription<TagTypes> | undefined | null>;\nexport type FullTagDescription<TagType> = {\n type: TagType;\n id?: number | string;\n};\nexport type TagDescription<TagType> = TagType | FullTagDescription<TagType>;\n\n/**\n * @public\n */\nexport type ResultDescription<TagTypes extends string, ResultType, QueryArg, ErrorType, MetaType> = ReadonlyArray<TagDescription<TagTypes> | undefined | null> | GetResultDescriptionFn<TagTypes, ResultType, QueryArg, ErrorType, MetaType>;\ntype QueryTypes<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = BaseEndpointTypes<QueryArg, BaseQuery, ResultType> & {\n /**\n * The endpoint definition type. To be used with some internal generic types.\n * @example\n * ```ts\n * const useMyWrappedHook: UseQuery<typeof api.endpoints.query.Types.QueryDefinition> = ...\n * ```\n */\n QueryDefinition: QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;\n TagTypes: TagTypes;\n ReducerPath: ReducerPath;\n};\n\n/**\n * @public\n */\nexport interface QueryExtraOptions<TagTypes extends string, ResultType, QueryArg, BaseQuery extends BaseQueryFn, ReducerPath extends string = string> extends CacheLifecycleQueryExtraOptions<ResultType, QueryArg, BaseQuery, ReducerPath>, QueryLifecycleQueryExtraOptions<ResultType, QueryArg, BaseQuery, ReducerPath>, CacheCollectionQueryExtraOptions {\n type: DefinitionType.query;\n\n /**\n * Used by `query` endpoints. Determines which 'tag' is attached to the cached data returned by the query.\n * Expects an array of tag type strings, an array of objects of tag types with ids, or a function that returns such an array.\n * 1. `['Post']` - equivalent to `2`\n * 2. `[{ type: 'Post' }]` - equivalent to `1`\n * 3. `[{ type: 'Post', id: 1 }]`\n * 4. `(result, error, arg) => ['Post']` - equivalent to `5`\n * 5. `(result, error, arg) => [{ type: 'Post' }]` - equivalent to `4`\n * 6. `(result, error, arg) => [{ type: 'Post', id: 1 }]`\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"providesTags example\"\n *\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n * type PostsResponse = Post[]\n *\n * const api = createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * tagTypes: ['Posts'],\n * endpoints: (build) => ({\n * getPosts: build.query<PostsResponse, void>({\n * query: () => 'posts',\n * // highlight-start\n * providesTags: (result) =>\n * result\n * ? [\n * ...result.map(({ id }) => ({ type: 'Posts' as const, id })),\n * { type: 'Posts', id: 'LIST' },\n * ]\n * : [{ type: 'Posts', id: 'LIST' }],\n * // highlight-end\n * })\n * })\n * })\n * ```\n */\n providesTags?: ResultDescription<TagTypes, ResultType, QueryArg, BaseQueryError<BaseQuery>, BaseQueryMeta<BaseQuery>>;\n /**\n * Not to be used. A query should not invalidate tags in the cache.\n */\n invalidatesTags?: never;\n\n /**\n * Can be provided to return a custom cache key value based on the query arguments.\n *\n * This is primarily intended for cases where a non-serializable value is passed as part of the query arg object and should be excluded from the cache key. It may also be used for cases where an endpoint should only have a single cache entry, such as an infinite loading / pagination implementation.\n *\n * Unlike the `createApi` version which can _only_ return a string, this per-endpoint option can also return an an object, number, or boolean. If it returns a string, that value will be used as the cache key directly. If it returns an object / number / boolean, that value will be passed to the built-in `defaultSerializeQueryArgs`. This simplifies the use case of stripping out args you don't want included in the cache key.\n *\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"serializeQueryArgs : exclude value\"\n *\n * import { createApi, fetchBaseQuery, defaultSerializeQueryArgs } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n *\n * interface MyApiClient {\n * fetchPost: (id: string) => Promise<Post>\n * }\n *\n * createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * endpoints: (build) => ({\n * // Example: an endpoint with an API client passed in as an argument,\n * // but only the item ID should be used as the cache key\n * getPost: build.query<Post, { id: string; client: MyApiClient }>({\n * queryFn: async ({ id, client }) => {\n * const post = await client.fetchPost(id)\n * return { data: post }\n * },\n * // highlight-start\n * serializeQueryArgs: ({ queryArgs, endpointDefinition, endpointName }) => {\n * const { id } = queryArgs\n * // This can return a string, an object, a number, or a boolean.\n * // If it returns an object, number or boolean, that value\n * // will be serialized automatically via `defaultSerializeQueryArgs`\n * return { id } // omit `client` from the cache key\n *\n * // Alternately, you can use `defaultSerializeQueryArgs` yourself:\n * // return defaultSerializeQueryArgs({\n * // endpointName,\n * // queryArgs: { id },\n * // endpointDefinition\n * // })\n * // Or create and return a string yourself:\n * // return `getPost(${id})`\n * },\n * // highlight-end\n * }),\n * }),\n *})\n * ```\n */\n serializeQueryArgs?: SerializeQueryArgs<QueryArg, string | number | boolean | Record<any, any>>;\n\n /**\n * Can be provided to merge an incoming response value into the current cache data.\n * If supplied, no automatic structural sharing will be applied - it's up to\n * you to update the cache appropriately.\n *\n * Since RTKQ normally replaces cache entries with the new response, you will usually\n * need to use this with the `serializeQueryArgs` or `forceRefetch` options to keep\n * an existing cache entry so that it can be updated.\n *\n * Since this is wrapped with Immer, you may either mutate the `currentCacheValue` directly,\n * or return a new value, but _not_ both at once.\n *\n * Will only be called if the existing `currentCacheData` is _not_ `undefined` - on first response,\n * the cache entry will just save the response data directly.\n *\n * Useful if you don't want a new request to completely override the current cache value,\n * maybe because you have manually updated it from another source and don't want those\n * updates to get lost.\n *\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"merge: pagination\"\n *\n * import { createApi, fetchBaseQuery, defaultSerializeQueryArgs } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n *\n * createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * endpoints: (build) => ({\n * listItems: build.query<string[], number>({\n * query: (pageNumber) => `/listItems?page=${pageNumber}`,\n * // Only have one cache entry because the arg always maps to one string\n * serializeQueryArgs: ({ endpointName }) => {\n * return endpointName\n * },\n * // Always merge incoming data to the cache entry\n * merge: (currentCache, newItems) => {\n * currentCache.push(...newItems)\n * },\n * // Refetch when the page arg changes\n * forceRefetch({ currentArg, previousArg }) {\n * return currentArg !== previousArg\n * },\n * }),\n * }),\n *})\n * ```\n */\n merge?(currentCacheData: ResultType, responseData: ResultType, otherArgs: {\n arg: QueryArg;\n baseQueryMeta: BaseQueryMeta<BaseQuery>;\n requestId: string;\n fulfilledTimeStamp: number;\n }): ResultType | void;\n\n /**\n * Check to see if the endpoint should force a refetch in cases where it normally wouldn't.\n * This is primarily useful for \"infinite scroll\" / pagination use cases where\n * RTKQ is keeping a single cache entry that is added to over time, in combination\n * with `serializeQueryArgs` returning a fixed cache key and a `merge` callback\n * set to add incoming data to the cache entry each time.\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"forceRefresh: pagination\"\n *\n * import { createApi, fetchBaseQuery, defaultSerializeQueryArgs } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n *\n * createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * endpoints: (build) => ({\n * listItems: build.query<string[], number>({\n * query: (pageNumber) => `/listItems?page=${pageNumber}`,\n * // Only have one cache entry because the arg always maps to one string\n * serializeQueryArgs: ({ endpointName }) => {\n * return endpointName\n * },\n * // Always merge incoming data to the cache entry\n * merge: (currentCache, newItems) => {\n * currentCache.push(...newItems)\n * },\n * // Refetch when the page arg changes\n * forceRefetch({ currentArg, previousArg }) {\n * return currentArg !== previousArg\n * },\n * }),\n * }),\n *})\n * ```\n */\n forceRefetch?(params: {\n currentArg: QueryArg | undefined;\n previousArg: QueryArg | undefined;\n state: RootState<any, any, string>;\n endpointState?: QuerySubState<any>;\n }): boolean;\n\n /**\n * All of these are `undefined` at runtime, purely to be used in TypeScript declarations!\n */\n Types?: QueryTypes<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;\n}\nexport type QueryDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & QueryExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath>;\nexport type InfiniteQueryTypes<QueryArg, PageParam, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = BaseEndpointTypes<QueryArg, BaseQuery, ResultType> & {\n /**\n * The endpoint definition type. To be used with some internal generic types.\n * @example\n * ```ts\n * const useMyWrappedHook: UseQuery<typeof api.endpoints.query.Types.QueryDefinition> = ...\n * ```\n */\n InfiniteQueryDefinition: InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, TagTypes, ResultType, ReducerPath>;\n TagTypes: TagTypes;\n ReducerPath: ReducerPath;\n};\nexport interface InfiniteQueryExtraOptions<TagTypes extends string, ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, ReducerPath extends string = string> extends CacheLifecycleInfiniteQueryExtraOptions<InfiniteData<ResultType, PageParam>, QueryArg, BaseQuery, ReducerPath>, QueryLifecycleInfiniteQueryExtraOptions<InfiniteData<ResultType, PageParam>, QueryArg, BaseQuery, ReducerPath>, CacheCollectionQueryExtraOptions {\n type: DefinitionType.infinitequery;\n providesTags?: ResultDescription<TagTypes, InfiniteData<ResultType, PageParam>, QueryArg, BaseQueryError<BaseQuery>, BaseQueryMeta<BaseQuery>>;\n /**\n * Not to be used. A query should not invalidate tags in the cache.\n */\n invalidatesTags?: never;\n\n /**\n * Required options to configure the infinite query behavior.\n * `initialPageParam` and `getNextPageParam` are required, to\n * ensure the infinite query can properly fetch the next page of data.\n * `initialPageParam` may be specified when using the\n * endpoint, to override the default value.\n * `maxPages` and `getPreviousPageParam` are both optional.\n * \n * @example\n * \n * ```ts\n * // codeblock-meta title=\"infiniteQueryOptions example\"\n * import { createApi, fetchBaseQuery, defaultSerializeQueryArgs } from '@reduxjs/toolkit/query/react'\n * \n * type Pokemon = {\n * id: string\n * name: string\n * }\n * \n * const pokemonApi = createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),\n * endpoints: (build) => ({\n * getInfinitePokemonWithMax: build.infiniteQuery<Pokemon[], string, number>({\n * infiniteQueryOptions: {\n * initialPageParam: 0,\n * maxPages: 3,\n * getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) =>\n * lastPageParam + 1,\n * getPreviousPageParam: (\n * firstPage,\n * allPages,\n * firstPageParam,\n * allPageParams,\n * ) => {\n * return firstPageParam > 0 ? firstPageParam - 1 : undefined\n * },\n * },\n * query({pageParam}) {\n * return `https://example.com/listItems?page=${pageParam}`\n * },\n * }),\n * }),\n * })\n \n * ```\n */\n infiniteQueryOptions: InfiniteQueryConfigOptions<ResultType, PageParam>;\n\n /**\n * Can be provided to return a custom cache key value based on the query arguments.\n *\n * This is primarily intended for cases where a non-serializable value is passed as part of the query arg object and should be excluded from the cache key. It may also be used for cases where an endpoint should only have a single cache entry, such as an infinite loading / pagination implementation.\n *\n * Unlike the `createApi` version which can _only_ return a string, this per-endpoint option can also return an an object, number, or boolean. If it returns a string, that value will be used as the cache key directly. If it returns an object / number / boolean, that value will be passed to the built-in `defaultSerializeQueryArgs`. This simplifies the use case of stripping out args you don't want included in the cache key.\n *\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"serializeQueryArgs : exclude value\"\n *\n * import { createApi, fetchBaseQuery, defaultSerializeQueryArgs } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n *\n * interface MyApiClient {\n * fetchPost: (id: string) => Promise<Post>\n * }\n *\n * createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * endpoints: (build) => ({\n * // Example: an endpoint with an API client passed in as an argument,\n * // but only the item ID should be used as the cache key\n * getPost: build.query<Post, { id: string; client: MyApiClient }>({\n * queryFn: async ({ id, client }) => {\n * const post = await client.fetchPost(id)\n * return { data: post }\n * },\n * // highlight-start\n * serializeQueryArgs: ({ queryArgs, endpointDefinition, endpointName }) => {\n * const { id } = queryArgs\n * // This can return a string, an object, a number, or a boolean.\n * // If it returns an object, number or boolean, that value\n * // will be serialized automatically via `defaultSerializeQueryArgs`\n * return { id } // omit `client` from the cache key\n *\n * // Alternately, you can use `defaultSerializeQueryArgs` yourself:\n * // return defaultSerializeQueryArgs({\n * // endpointName,\n * // queryArgs: { id },\n * // endpointDefinition\n * // })\n * // Or create and return a string yourself:\n * // return `getPost(${id})`\n * },\n * // highlight-end\n * }),\n * }),\n *})\n * ```\n */\n serializeQueryArgs?: SerializeQueryArgs<QueryArg, string | number | boolean | Record<any, any>>;\n\n /**\n * All of these are `undefined` at runtime, purely to be used in TypeScript declarations!\n */\n Types?: InfiniteQueryTypes<QueryArg, PageParam, BaseQuery, TagTypes, ResultType, ReducerPath>;\n}\nexport type InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> =\n// Infinite query endpoints receive `{queryArg, pageParam}`\nBaseEndpointDefinition<InfiniteQueryCombinedArg<QueryArg, PageParam>, BaseQuery, ResultType> & InfiniteQueryExtraOptions<TagTypes, ResultType, QueryArg, PageParam, BaseQuery, ReducerPath>;\ntype MutationTypes<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = BaseEndpointTypes<QueryArg, BaseQuery, ResultType> & {\n /**\n * The endpoint definition type. To be used with some internal generic types.\n * @example\n * ```ts\n * const useMyWrappedHook: UseMutation<typeof api.endpoints.query.Types.MutationDefinition> = ...\n * ```\n */\n MutationDefinition: MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;\n TagTypes: TagTypes;\n ReducerPath: ReducerPath;\n};\n\n/**\n * @public\n */\nexport interface MutationExtraOptions<TagTypes extends string, ResultType, QueryArg, BaseQuery extends BaseQueryFn, ReducerPath extends string = string> extends CacheLifecycleMutationExtraOptions<ResultType, QueryArg, BaseQuery, ReducerPath>, QueryLifecycleMutationExtraOptions<ResultType, QueryArg, BaseQuery, ReducerPath> {\n type: DefinitionType.mutation;\n\n /**\n * Used by `mutation` endpoints. Determines which cached data should be either re-fetched or removed from the cache.\n * Expects the same shapes as `providesTags`.\n *\n * @example\n *\n * ```ts\n * // codeblock-meta title=\"invalidatesTags example\"\n * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'\n * interface Post {\n * id: number\n * name: string\n * }\n * type PostsResponse = Post[]\n *\n * const api = createApi({\n * baseQuery: fetchBaseQuery({ baseUrl: '/' }),\n * tagTypes: ['Posts'],\n * endpoints: (build) => ({\n * getPosts: build.query<PostsResponse, void>({\n * query: () => 'posts',\n * providesTags: (result) =>\n * result\n * ? [\n * ...result.map(({ id }) => ({ type: 'Posts' as const, id })),\n * { type: 'Posts', id: 'LIST' },\n * ]\n * : [{ type: 'Posts', id: 'LIST' }],\n * }),\n * addPost: build.mutation<Post, Partial<Post>>({\n * query(body) {\n * return {\n * url: `posts`,\n * method: 'POST',\n * body,\n * }\n * },\n * // highlight-start\n * invalidatesTags: [{ type: 'Posts', id: 'LIST' }],\n * // highlight-end\n * }),\n * })\n * })\n * ```\n */\n invalidatesTags?: ResultDescription<TagTypes, ResultType, QueryArg, BaseQueryError<BaseQuery>, BaseQueryMeta<BaseQuery>>;\n /**\n * Not to be used. A mutation should not provide tags to the cache.\n */\n providesTags?: never;\n\n /**\n * All of these are `undefined` at runtime, purely to be used in TypeScript declarations!\n */\n Types?: MutationTypes<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;\n}\nexport type MutationDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string> = BaseEndpointDefinition<QueryArg, BaseQuery, ResultType> & MutationExtraOptions<TagTypes, ResultType, QueryArg, BaseQuery, ReducerPath>;\nexport type EndpointDefinition<QueryArg, BaseQuery extends BaseQueryFn, TagTypes extends string, ResultType, ReducerPath extends string = string, PageParam = any> = QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath> | MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath> | InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, TagTypes, ResultType, ReducerPath>;\nexport type EndpointDefinitions = Record<string, EndpointDefinition<any, any, any, any>>;\nexport function isQueryDefinition(e: EndpointDefinition<any, any, any, any>): e is QueryDefinition<any, any, any, any> {\n return e.type === DefinitionType.query;\n}\nexport function isMutationDefinition(e: EndpointDefinition<any, any, any, any>): e is MutationDefinition<any, any, any, any> {\n return e.type === DefinitionType.mutation;\n}\nexport function isInfiniteQueryDefinition(e: EndpointDefinition<any, any, any, any>): e is InfiniteQueryDefinition<any, any, any, any, any> {\n return e.type === DefinitionType.infinitequery;\n}\nexport type EndpointBuilder<BaseQuery extends BaseQueryFn, TagTypes extends string, ReducerPath extends string> = {\n /**\n * An endpoint definition that retrieves data, and may provide tags to the cache.\n *\n * @example\n * ```js\n * // codeblock-meta title=\"Example of all query endpoint options\"\n * const api = createApi({\n * baseQuery,\n * endpoints: (build) => ({\n * getPost: build.query({\n * query: (id) => ({ url: `post/${id}` }),\n * // Pick out data and prevent nested properties in a hook or selector\n * transformResponse: (response) => response.data,\n * // Pick out error and prevent nested properties in a hook or selector\n * transformErrorResponse: (response) => response.error,\n * // `result` is the server response\n * providesTags: (result, error, id) => [{ type: 'Post', id }],\n * // trigger side effects or optimistic updates\n * onQueryStarted(id, { dispatch, getState, extra, requestId, queryFulfilled, getCacheEntry, updateCachedData }) {},\n * // handle subscriptions etc\n * onCacheEntryAdded(id, { dispatch, getState, extra, requestId, cacheEntryRemoved, cacheDataLoaded, getCacheEntry, updateCachedData }) {},\n * }),\n * }),\n *});\n *```\n */\n query<ResultType, QueryArg>(definition: OmitFromUnion<QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>, 'type'>): QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;\n /**\n * An endpoint definition that alters data on the server or will possibly invalidate the cache.\n *\n * @example\n * ```js\n * // codeblock-meta title=\"Example of all mutation endpoint options\"\n * const api = createApi({\n * baseQuery,\n * endpoints: (build) => ({\n * updatePost: build.mutation({\n * query: ({ id, ...patch }) => ({ url: `post/${id}`, method: 'PATCH', body: patch }),\n * // Pick out data and prevent nested properties in a hook or selector\n * transformResponse: (response) => response.data,\n * // Pick out error and prevent nested properties in a hook or selector\n * transformErrorResponse: (response) => response.error,\n * // `result` is the server response\n * invalidatesTags: (result, error, id) => [{ type: 'Post', id }],\n * // trigger side effects or optimistic updates\n * onQueryStarted(id, { dispatch, getState, extra, requestId, queryFulfilled, getCacheEntry }) {},\n * // handle subscriptions etc\n * onCacheEntryAdded(id, { dispatch, getState, extra, requestId, cacheEntryRemoved, cacheDataLoaded, getCacheEntry }) {},\n * }),\n * }),\n * });\n * ```\n */\n mutation<ResultType, QueryArg>(definition: OmitFromUnion<MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>, 'type'>): MutationDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>;\n infiniteQuery<ResultType, QueryArg, PageParam>(definition: OmitFromUnion<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, TagTypes, ResultType, ReducerPath>, 'type'>): InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, TagTypes, ResultType, ReducerPath>;\n};\nexport type AssertTagTypes = <T extends FullTagDescription<string>>(t: T) => T;\nexport function calculateProvidedBy<ResultType, QueryArg, ErrorType, MetaType>(description: ResultDescription<string, ResultType, QueryArg, ErrorType, MetaType> | undefined, result: ResultType | undefined, error: ErrorType | undefined, queryArg: QueryArg, meta: MetaType | undefined, assertTagTypes: AssertTagTypes): readonly FullTagDescription<string>[] {\n if (isFunction(description)) {\n return description(result as ResultType, error as undefined, queryArg, meta as MetaType).filter(isNotNullish).map(expandTagDescription).map(assertTagTypes);\n }\n if (Array.isArray(description)) {\n return description.map(expandTagDescription).map(assertTagTypes);\n }\n return [];\n}\nfunction isFunction<T>(t: T): t is Extract<T, Function> {\n return typeof t === 'function';\n}\nexport function expandTagDescription(description: TagDescription<string>): FullTagDescription<string> {\n return typeof description === 'string' ? {\n type: description\n } : description;\n}\nexport type QueryArgFrom<D extends BaseEndpointDefinition<any, any, any>> = D extends BaseEndpointDefinition<infer QA, any, any> ? QA : never;\n\n// Just extracting `QueryArg` from `BaseEndpointDefinition`\n// doesn't sufficiently match here.\n// We need to explicitly match against `InfiniteQueryDefinition`\nexport type InfiniteQueryArgFrom<D extends BaseEndpointDefinition<any, any, any>> = D extends InfiniteQueryDefinition<infer QA, any, any, any, any> ? QA : never;\nexport type QueryArgFromAnyQuery<D extends BaseEndpointDefinition<any, any, any>> = D extends InfiniteQueryDefinition<any, any, any, any, any> ? InfiniteQueryArgFrom<D> : D extends QueryDefinition<any, any, any, any> ? QueryArgFrom<D> : never;\nexport type ResultTypeFrom<D extends BaseEndpointDefinition<any, any, any>> = D extends BaseEndpointDefinition<any, any, infer RT> ? RT : unknown;\nexport type ReducerPathFrom<D extends EndpointDefinition<any, any, any, any, any>> = D extends EndpointDefinition<any, any, any, any, infer RP> ? RP : unknown;\nexport type TagTypesFrom<D extends EndpointDefinition<any, any, any, any>> = D extends EndpointDefinition<any, any, infer RP, any> ? RP : unknown;\nexport type PageParamFrom<D extends InfiniteQueryDefinition<any, any, any, any, any>> = D extends InfiniteQueryDefinition<any, infer PP, any, any, any> ? PP : unknown;\nexport type InfiniteQueryCombinedArg<QueryArg, PageParam> = {\n queryArg: QueryArg;\n pageParam: PageParam;\n};\nexport type TagTypesFromApi<T> = T extends Api<any, any, any, infer TagTypes> ? TagTypes : never;\nexport type DefinitionsFromApi<T> = T extends Api<any, infer Definitions, any, any> ? Definitions : never;\nexport type TransformedResponse<NewDefinitions extends EndpointDefinitions, K, ResultType> = K extends keyof NewDefinitions ? NewDefinitions[K]['transformResponse'] extends undefined ? ResultType : UnwrapPromise<ReturnType<NonUndefined<NewDefinitions[K]['transformResponse']>>> : ResultType;\nexport type OverrideResultType<Definition, NewResultType> = Definition extends QueryDefinition<infer QueryArg, infer BaseQuery, infer TagTypes, any, infer ReducerPath> ? QueryDefinition<QueryArg, BaseQuery, TagTypes, NewResultType, ReducerPath> : Definition extends MutationDefinition<infer QueryArg, infer BaseQuery, infer TagTypes, any, infer ReducerPath> ? MutationDefinition<QueryArg, BaseQuery, TagTypes, NewResultType, ReducerPath> : Definition extends InfiniteQueryDefinition<infer QueryArg, infer PageParam, infer BaseQuery, infer TagTypes, any, infer ReducerPath> ? InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, TagTypes, NewResultType, ReducerPath> : never;\nexport type UpdateDefinitions<Definitions extends EndpointDefinitions, NewTagTypes extends string, NewDefinitions extends EndpointDefinitions> = { [K in keyof Definitions]: Definitions[K] extends QueryDefinition<infer QueryArg, infer BaseQuery, any, infer ResultType, infer ReducerPath> ? QueryDefinition<QueryArg, BaseQuery, NewTagTypes, TransformedResponse<NewDefinitions, K, ResultType>, ReducerPath> : Definitions[K] extends MutationDefinition<infer QueryArg, infer BaseQuery, any, infer ResultType, infer ReducerPath> ? MutationDefinition<QueryArg, BaseQuery, NewTagTypes, TransformedResponse<NewDefinitions, K, ResultType>, ReducerPath> : Definitions[K] extends InfiniteQueryDefinition<infer QueryArg, infer PageParam, infer BaseQuery, any, infer ResultType, infer ReducerPath> ? InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, NewTagTypes, TransformedResponse<NewDefinitions, K, ResultType>, ReducerPath> : never };","export type Id<T> = { [K in keyof T]: T[K] } & {};\nexport type WithRequiredProp<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;\nexport type Override<T1, T2> = T2 extends any ? Omit<T1, keyof T2> & T2 : never;\nexport function assertCast<T>(v: any): asserts v is T {}\nexport function safeAssign<T extends object>(target: T, ...args: Array<Partial<NoInfer<T>>>): T {\n return Object.assign(target, ...args);\n}\n\n/**\n * Convert a Union type `(A|B)` to an intersection type `(A&B)`\n */\nexport type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\nexport type NonOptionalKeys<T> = { [K in keyof T]-?: undefined extends T[K] ? never : K }[keyof T];\nexport type HasRequiredProps<T, True, False> = NonOptionalKeys<T> extends never ? False : True;\nexport type OptionalIfAllPropsOptional<T> = HasRequiredProps<T, T, T | never>;\nexport type NoInfer<T> = [T][T extends any ? 0 : never];\nexport type NonUndefined<T> = T extends undefined ? never : T;\nexport type UnwrapPromise<T> = T extends PromiseLike<infer V> ? V : T;\nexport type MaybePromise<T> = T | PromiseLike<T>;\nexport type OmitFromUnion<T, K extends keyof T> = T extends any ? Omit<T, K> : never;\nexport type IsAny<T, True, False = never> = true | false extends (T extends never ? true : false) ? True : False;\nexport type CastAny<T, CastTo> = IsAny<T, CastTo, T>;","import { formatProdErrorMessage as _formatProdErrorMessage, formatProdErrorMessage as _formatProdErrorMessage2 } from \"@reduxjs/toolkit\";\nimport type { Selector, ThunkAction, ThunkDispatch, UnknownAction } from '@reduxjs/toolkit';\nimport type { Api, ApiContext, ApiEndpointInfiniteQuery, ApiEndpointMutation, ApiEndpointQuery, BaseQueryFn, CoreModule, EndpointDefinitions, InfiniteQueryActionCreatorResult, InfiniteQueryArgFrom, InfiniteQueryDefinition, InfiniteQueryResultSelectorResult, InfiniteQuerySubState, MutationActionCreatorResult, MutationDefinition, MutationResultSelectorResult, PageParamFrom, PrefetchOptions, QueryActionCreatorResult, QueryArgFrom, QueryCacheKey, QueryDefinition, QueryKeys, QueryResultSelectorResult, QuerySubState, ResultTypeFrom, RootState, SerializeQueryArgs, SkipToken, SubscriptionOptions, TSHelpersId, TSHelpersNoInfer, TSHelpersOverride } from '@reduxjs/toolkit/query';\nimport { defaultSerializeQueryArgs, QueryStatus, skipToken } from '@reduxjs/toolkit/query';\nimport type { DependencyList } from 'react';\nimport { useCallback, useDebugValue, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { shallowEqual } from 'react-redux';\nimport type { SubscriptionSelectors } from '../core/buildMiddleware/index';\nimport type { InfiniteData, InfiniteQueryConfigOptions } from '../core/index';\nimport type { UninitializedValue } from './constants';\nimport { UNINITIALIZED_VALUE } from './constants';\nimport type { ReactHooksModuleOptions } from './module';\nimport { useStableQueryArgs } from './useSerializedStableValue';\nimport { useShallowStableValue } from './useShallowStableValue';\nimport type { InfiniteQueryDirection } from '../core/apiState';\nimport { isInfiniteQueryDefinition } from '../endpointDefinitions';\nimport type { StartInfiniteQueryActionCreator } from '../core/buildInitiate';\n\n// Copy-pasted from React-Redux\nconst canUseDOM = () => !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');\nconst isDOM = /* @__PURE__ */canUseDOM();\n\n// Under React Native, we know that we always want to use useLayoutEffect\n\nconst isRunningInReactNative = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';\nconst isReactNative = /* @__PURE__ */isRunningInReactNative();\nconst getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? useLayoutEffect : useEffect;\nexport const useIsomorphicLayoutEffect = /* @__PURE__ */getUseIsomorphicLayoutEffect();\nexport type QueryHooks<Definition extends QueryDefinition<any, any, any, any, any>> = {\n useQuery: UseQuery<Definition>;\n useLazyQuery: UseLazyQuery<Definition>;\n useQuerySubscription: UseQuerySubscription<Definition>;\n useLazyQuerySubscription: UseLazyQuerySubscription<Definition>;\n useQueryState: UseQueryState<Definition>;\n};\nexport type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {\n useInfiniteQuery: UseInfiniteQuery<Definition>;\n useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;\n useInfiniteQueryState: UseInfiniteQueryState<Definition>;\n};\nexport ty