Spaces:
Sleeping
Sleeping
Upload 243 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- frontend/node_modules/@reduxjs/toolkit/LICENSE +21 -0
- frontend/node_modules/@reduxjs/toolkit/README.md +110 -0
- frontend/node_modules/@reduxjs/toolkit/dist/cjs/index.js +6 -0
- frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs +2362 -0
- frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs +3 -0
- frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/index.d.mts +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/index.d.ts +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/index.js +6 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs +2 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.mts +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.ts +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/index.js +6 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs +759 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs +2 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.mts +959 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts +959 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs +2 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js +753 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs +718 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs +2 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs +2885 -0
- frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs.map +0 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/index.js +6 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs +55 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs.map +1 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs +2 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs.map +1 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.mts +22 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.ts +22 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs +2 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs.map +1 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js +47 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js.map +1 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs +28 -0
- frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs.map +1 -0
- frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs +3 -0
- frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs.map +0 -0
frontend/node_modules/@reduxjs/toolkit/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Mark Erikson
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
frontend/node_modules/@reduxjs/toolkit/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Redux Toolkit
|
| 2 |
+
|
| 3 |
+

|
| 4 |
+
[](https://www.npmjs.com/package/@reduxjs/toolkit)
|
| 5 |
+
[](https://www.npmjs.com/package/@reduxjs/toolkit)
|
| 6 |
+
|
| 7 |
+
**The official, opinionated, batteries-included toolset for efficient Redux development**
|
| 8 |
+
|
| 9 |
+
## Installation
|
| 10 |
+
|
| 11 |
+
### Create a React Redux App
|
| 12 |
+
|
| 13 |
+
The recommended way to start new apps with React and Redux Toolkit is by using [our official Redux Toolkit + TS template for Vite](https://github.com/reduxjs/redux-templates), or by creating a new Next.js project using [Next's `with-redux` template](https://github.com/vercel/next.js/tree/canary/examples/with-redux).
|
| 14 |
+
|
| 15 |
+
Both of these already have Redux Toolkit and React-Redux configured appropriately for that build tool, and come with a small example app that demonstrates how to use several of Redux Toolkit's features.
|
| 16 |
+
|
| 17 |
+
```bash
|
| 18 |
+
# Vite with our Redux+TS template
|
| 19 |
+
# (using the `degit` tool to clone and extract the template)
|
| 20 |
+
npx degit reduxjs/redux-templates/packages/vite-template-redux my-app
|
| 21 |
+
|
| 22 |
+
# Next.js using the `with-redux` template
|
| 23 |
+
npx create-next-app --example with-redux my-app
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
We do not currently have official React Native templates, but recommend these templates for standard React Native and for Expo:
|
| 27 |
+
|
| 28 |
+
- https://github.com/rahsheen/react-native-template-redux-typescript
|
| 29 |
+
- https://github.com/rahsheen/expo-template-redux-typescript
|
| 30 |
+
|
| 31 |
+
### An Existing App
|
| 32 |
+
|
| 33 |
+
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
# NPM
|
| 37 |
+
npm install @reduxjs/toolkit
|
| 38 |
+
|
| 39 |
+
# Yarn
|
| 40 |
+
yarn add @reduxjs/toolkit
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
The package includes a precompiled ESM build that can be used as a [`<script type="module">` tag](https://unpkg.com/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs) directly in the browser.
|
| 44 |
+
|
| 45 |
+
## Documentation
|
| 46 |
+
|
| 47 |
+
The Redux Toolkit docs are available at **https://redux-toolkit.js.org**, including API references and usage guides for all of the APIs included in Redux Toolkit.
|
| 48 |
+
|
| 49 |
+
The Redux core docs at https://redux.js.org includes the full Redux tutorials, as well usage guides on general Redux patterns.
|
| 50 |
+
|
| 51 |
+
## Purpose
|
| 52 |
+
|
| 53 |
+
The **Redux Toolkit** package is intended to be the standard way to write Redux logic. It was originally created to help address three common concerns about Redux:
|
| 54 |
+
|
| 55 |
+
- "Configuring a Redux store is too complicated"
|
| 56 |
+
- "I have to add a lot of packages to get Redux to do anything useful"
|
| 57 |
+
- "Redux requires too much boilerplate code"
|
| 58 |
+
|
| 59 |
+
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
|
| 60 |
+
|
| 61 |
+
Because of that, this package is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", folder or file structures, managing entity relationships in the store, and so on.
|
| 62 |
+
|
| 63 |
+
Redux Toolkit also includes a powerful data fetching and caching capability that we've dubbed "RTK Query". It's included in the package as a separate set of entry points. It's optional, but can eliminate the need to hand-write data fetching logic yourself.
|
| 64 |
+
|
| 65 |
+
## What's Included
|
| 66 |
+
|
| 67 |
+
Redux Toolkit includes these APIs:
|
| 68 |
+
|
| 69 |
+
- `configureStore()`: wraps `createStore` to provide simplified configuration options and good defaults. It can automatically combine your slice reducers, add whatever Redux middleware you supply, includes `redux-thunk` by default, and enables use of the Redux DevTools Extension.
|
| 70 |
+
- `createReducer()`: lets you supply a lookup table of action types to case reducer functions, rather than writing switch statements. In addition, it automatically uses the [`immer` library](https://github.com/mweststrate/immer) to let you write simpler immutable updates with normal mutative code, like `state.todos[3].completed = true`.
|
| 71 |
+
- `createAction()`: generates an action creator function for the given action type string. The function itself has `toString()` defined, so that it can be used in place of the type constant.
|
| 72 |
+
- `createSlice()`: combines `createReducer()` + `createAction()`. Accepts an object of reducer functions, a slice name, and an initial state value, and automatically generates a slice reducer with corresponding action creators and action types.
|
| 73 |
+
- `combineSlices()`: combines multiple slices into a single reducer, and allows "lazy loading" of slices after initialisation.
|
| 74 |
+
- `createListenerMiddleware()`: lets you define "listener" entries that contain an "effect" callback with additional logic, and a way to specify when that callback should run based on dispatched actions or state changes. A lightweight alternative to Redux async middleware like sagas and observables.
|
| 75 |
+
- `createAsyncThunk()`: accepts an action type string and a function that returns a promise, and generates a thunk that dispatches `pending/resolved/rejected` action types based on that promise
|
| 76 |
+
- `createEntityAdapter()`: generates a set of reusable reducers and selectors to manage normalized data in the store
|
| 77 |
+
- The `createSelector()` utility from the [Reselect](https://github.com/reduxjs/reselect) library, re-exported for ease of use.
|
| 78 |
+
|
| 79 |
+
For details, see [the Redux Toolkit API Reference section in the docs](https://redux-toolkit.js.org/api/configureStore).
|
| 80 |
+
|
| 81 |
+
## RTK Query
|
| 82 |
+
|
| 83 |
+
**RTK Query** is provided as an optional addon within the `@reduxjs/toolkit` package. It is purpose-built to solve the use case of data fetching and caching, supplying a compact, but powerful toolset to define an API interface layer for your app. It is intended to simplify common cases for loading data in a web application, eliminating the need to hand-write data fetching & caching logic yourself.
|
| 84 |
+
|
| 85 |
+
RTK Query is built on top of the Redux Toolkit core for its implementation, using [Redux](https://redux.js.org/) internally for its architecture. Although knowledge of Redux and RTK are not required to use RTK Query, you should explore all of the additional global store management capabilities they provide, as well as installing the [Redux DevTools browser extension](https://github.com/reduxjs/redux-devtools), which works flawlessly with RTK Query to traverse and replay a timeline of your request & cache behavior.
|
| 86 |
+
|
| 87 |
+
RTK Query is included within the installation of the core Redux Toolkit package. It is available via either of the two entry points below:
|
| 88 |
+
|
| 89 |
+
```ts no-transpile
|
| 90 |
+
import { createApi } from '@reduxjs/toolkit/query'
|
| 91 |
+
|
| 92 |
+
/* React-specific entry point that automatically generates
|
| 93 |
+
hooks corresponding to the defined endpoints */
|
| 94 |
+
import { createApi } from '@reduxjs/toolkit/query/react'
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
### What's included
|
| 98 |
+
|
| 99 |
+
RTK Query includes these APIs:
|
| 100 |
+
|
| 101 |
+
- `createApi()`: The core of RTK Query's functionality. It allows you to define a set of endpoints describe how to retrieve data from a series of endpoints, including configuration of how to fetch and transform that data. In most cases, you should use this once per app, with "one API slice per base URL" as a rule of thumb.
|
| 102 |
+
- `fetchBaseQuery()`: A small wrapper around fetch that aims to simplify requests. Intended as the recommended baseQuery to be used in createApi for the majority of users.
|
| 103 |
+
- `<ApiProvider />`: Can be used as a Provider if you do not already have a Redux store.
|
| 104 |
+
- `setupListeners()`: A utility used to enable refetchOnMount and refetchOnReconnect behaviors.
|
| 105 |
+
|
| 106 |
+
See the [**RTK Query Overview**](https://redux-toolkit.js.org/rtk-query/overview) page for more details on what RTK Query is, what problems it solves, and how to use it.
|
| 107 |
+
|
| 108 |
+
## Contributing
|
| 109 |
+
|
| 110 |
+
Please refer to our [contributing guide](/CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Redux Toolkit.
|
frontend/node_modules/@reduxjs/toolkit/dist/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict'
|
| 2 |
+
if (process.env.NODE_ENV === 'production') {
|
| 3 |
+
module.exports = require('./redux-toolkit.production.min.cjs')
|
| 4 |
+
} else {
|
| 5 |
+
module.exports = require('./redux-toolkit.development.cjs')
|
| 6 |
+
}
|
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs
ADDED
|
@@ -0,0 +1,2362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
| 19 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 20 |
+
|
| 21 |
+
// src/index.ts
|
| 22 |
+
var src_exports = {};
|
| 23 |
+
__export(src_exports, {
|
| 24 |
+
ReducerType: () => ReducerType,
|
| 25 |
+
SHOULD_AUTOBATCH: () => SHOULD_AUTOBATCH,
|
| 26 |
+
TaskAbortError: () => TaskAbortError,
|
| 27 |
+
Tuple: () => Tuple,
|
| 28 |
+
addListener: () => addListener,
|
| 29 |
+
asyncThunkCreator: () => asyncThunkCreator,
|
| 30 |
+
autoBatchEnhancer: () => autoBatchEnhancer,
|
| 31 |
+
buildCreateSlice: () => buildCreateSlice,
|
| 32 |
+
clearAllListeners: () => clearAllListeners,
|
| 33 |
+
combineSlices: () => combineSlices,
|
| 34 |
+
configureStore: () => configureStore,
|
| 35 |
+
createAction: () => createAction,
|
| 36 |
+
createActionCreatorInvariantMiddleware: () => createActionCreatorInvariantMiddleware,
|
| 37 |
+
createAsyncThunk: () => createAsyncThunk,
|
| 38 |
+
createDraftSafeSelector: () => createDraftSafeSelector,
|
| 39 |
+
createDraftSafeSelectorCreator: () => createDraftSafeSelectorCreator,
|
| 40 |
+
createDynamicMiddleware: () => createDynamicMiddleware,
|
| 41 |
+
createEntityAdapter: () => createEntityAdapter,
|
| 42 |
+
createImmutableStateInvariantMiddleware: () => createImmutableStateInvariantMiddleware,
|
| 43 |
+
createListenerMiddleware: () => createListenerMiddleware,
|
| 44 |
+
createNextState: () => import_immer6.produce,
|
| 45 |
+
createReducer: () => createReducer,
|
| 46 |
+
createSelector: () => import_reselect2.createSelector,
|
| 47 |
+
createSelectorCreator: () => import_reselect2.createSelectorCreator,
|
| 48 |
+
createSerializableStateInvariantMiddleware: () => createSerializableStateInvariantMiddleware,
|
| 49 |
+
createSlice: () => createSlice,
|
| 50 |
+
current: () => import_immer6.current,
|
| 51 |
+
findNonSerializableValue: () => findNonSerializableValue,
|
| 52 |
+
formatProdErrorMessage: () => formatProdErrorMessage,
|
| 53 |
+
freeze: () => import_immer6.freeze,
|
| 54 |
+
isActionCreator: () => isActionCreator,
|
| 55 |
+
isAllOf: () => isAllOf,
|
| 56 |
+
isAnyOf: () => isAnyOf,
|
| 57 |
+
isAsyncThunkAction: () => isAsyncThunkAction,
|
| 58 |
+
isDraft: () => import_immer6.isDraft,
|
| 59 |
+
isFluxStandardAction: () => isFSA,
|
| 60 |
+
isFulfilled: () => isFulfilled,
|
| 61 |
+
isImmutableDefault: () => isImmutableDefault,
|
| 62 |
+
isPending: () => isPending,
|
| 63 |
+
isPlain: () => isPlain,
|
| 64 |
+
isRejected: () => isRejected,
|
| 65 |
+
isRejectedWithValue: () => isRejectedWithValue,
|
| 66 |
+
lruMemoize: () => import_reselect2.lruMemoize,
|
| 67 |
+
miniSerializeError: () => miniSerializeError,
|
| 68 |
+
nanoid: () => nanoid,
|
| 69 |
+
original: () => import_immer6.original,
|
| 70 |
+
prepareAutoBatched: () => prepareAutoBatched,
|
| 71 |
+
removeListener: () => removeListener,
|
| 72 |
+
unwrapResult: () => unwrapResult,
|
| 73 |
+
weakMapMemoize: () => import_reselect2.weakMapMemoize
|
| 74 |
+
});
|
| 75 |
+
module.exports = __toCommonJS(src_exports);
|
| 76 |
+
__reExport(src_exports, require("redux"), module.exports);
|
| 77 |
+
var import_immer6 = require("immer");
|
| 78 |
+
var import_reselect2 = require("reselect");
|
| 79 |
+
|
| 80 |
+
// src/createDraftSafeSelector.ts
|
| 81 |
+
var import_immer = require("immer");
|
| 82 |
+
var import_reselect = require("reselect");
|
| 83 |
+
var createDraftSafeSelectorCreator = (...args) => {
|
| 84 |
+
const createSelector2 = (0, import_reselect.createSelectorCreator)(...args);
|
| 85 |
+
const createDraftSafeSelector2 = Object.assign((...args2) => {
|
| 86 |
+
const selector = createSelector2(...args2);
|
| 87 |
+
const wrappedSelector = (value, ...rest) => selector((0, import_immer.isDraft)(value) ? (0, import_immer.current)(value) : value, ...rest);
|
| 88 |
+
Object.assign(wrappedSelector, selector);
|
| 89 |
+
return wrappedSelector;
|
| 90 |
+
}, {
|
| 91 |
+
withTypes: () => createDraftSafeSelector2
|
| 92 |
+
});
|
| 93 |
+
return createDraftSafeSelector2;
|
| 94 |
+
};
|
| 95 |
+
var createDraftSafeSelector = /* @__PURE__ */ createDraftSafeSelectorCreator(import_reselect.weakMapMemoize);
|
| 96 |
+
|
| 97 |
+
// src/configureStore.ts
|
| 98 |
+
var import_redux4 = require("redux");
|
| 99 |
+
|
| 100 |
+
// src/devtoolsExtension.ts
|
| 101 |
+
var import_redux = require("redux");
|
| 102 |
+
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
| 103 |
+
if (arguments.length === 0) return void 0;
|
| 104 |
+
if (typeof arguments[0] === "object") return import_redux.compose;
|
| 105 |
+
return import_redux.compose.apply(null, arguments);
|
| 106 |
+
};
|
| 107 |
+
var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
|
| 108 |
+
return function(noop3) {
|
| 109 |
+
return noop3;
|
| 110 |
+
};
|
| 111 |
+
};
|
| 112 |
+
|
| 113 |
+
// src/getDefaultMiddleware.ts
|
| 114 |
+
var import_redux_thunk = require("redux-thunk");
|
| 115 |
+
|
| 116 |
+
// src/createAction.ts
|
| 117 |
+
var import_redux2 = require("redux");
|
| 118 |
+
|
| 119 |
+
// src/tsHelpers.ts
|
| 120 |
+
var hasMatchFunction = (v) => {
|
| 121 |
+
return v && typeof v.match === "function";
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
// src/createAction.ts
|
| 125 |
+
function createAction(type, prepareAction) {
|
| 126 |
+
function actionCreator(...args) {
|
| 127 |
+
if (prepareAction) {
|
| 128 |
+
let prepared = prepareAction(...args);
|
| 129 |
+
if (!prepared) {
|
| 130 |
+
throw new Error(false ? _formatProdErrorMessage(0) : "prepareAction did not return an object");
|
| 131 |
+
}
|
| 132 |
+
return {
|
| 133 |
+
type,
|
| 134 |
+
payload: prepared.payload,
|
| 135 |
+
..."meta" in prepared && {
|
| 136 |
+
meta: prepared.meta
|
| 137 |
+
},
|
| 138 |
+
..."error" in prepared && {
|
| 139 |
+
error: prepared.error
|
| 140 |
+
}
|
| 141 |
+
};
|
| 142 |
+
}
|
| 143 |
+
return {
|
| 144 |
+
type,
|
| 145 |
+
payload: args[0]
|
| 146 |
+
};
|
| 147 |
+
}
|
| 148 |
+
actionCreator.toString = () => `${type}`;
|
| 149 |
+
actionCreator.type = type;
|
| 150 |
+
actionCreator.match = (action) => (0, import_redux2.isAction)(action) && action.type === type;
|
| 151 |
+
return actionCreator;
|
| 152 |
+
}
|
| 153 |
+
function isActionCreator(action) {
|
| 154 |
+
return typeof action === "function" && "type" in action && // hasMatchFunction only wants Matchers but I don't see the point in rewriting it
|
| 155 |
+
hasMatchFunction(action);
|
| 156 |
+
}
|
| 157 |
+
function isFSA(action) {
|
| 158 |
+
return (0, import_redux2.isAction)(action) && Object.keys(action).every(isValidKey);
|
| 159 |
+
}
|
| 160 |
+
function isValidKey(key) {
|
| 161 |
+
return ["type", "payload", "error", "meta"].indexOf(key) > -1;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
// src/actionCreatorInvariantMiddleware.ts
|
| 165 |
+
function getMessage(type) {
|
| 166 |
+
const splitType = type ? `${type}`.split("/") : [];
|
| 167 |
+
const actionName = splitType[splitType.length - 1] || "actionCreator";
|
| 168 |
+
return `Detected an action creator with type "${type || "unknown"}" being dispatched.
|
| 169 |
+
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${actionName}())\` instead of \`dispatch(${actionName})\`. This is necessary even if the action has no payload.`;
|
| 170 |
+
}
|
| 171 |
+
function createActionCreatorInvariantMiddleware(options = {}) {
|
| 172 |
+
if (false) {
|
| 173 |
+
return () => (next) => (action) => next(action);
|
| 174 |
+
}
|
| 175 |
+
const {
|
| 176 |
+
isActionCreator: isActionCreator2 = isActionCreator
|
| 177 |
+
} = options;
|
| 178 |
+
return () => (next) => (action) => {
|
| 179 |
+
if (isActionCreator2(action)) {
|
| 180 |
+
console.warn(getMessage(action.type));
|
| 181 |
+
}
|
| 182 |
+
return next(action);
|
| 183 |
+
};
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
// src/utils.ts
|
| 187 |
+
var import_immer2 = require("immer");
|
| 188 |
+
function getTimeMeasureUtils(maxDelay, fnName) {
|
| 189 |
+
let elapsed = 0;
|
| 190 |
+
return {
|
| 191 |
+
measureTime(fn) {
|
| 192 |
+
const started = Date.now();
|
| 193 |
+
try {
|
| 194 |
+
return fn();
|
| 195 |
+
} finally {
|
| 196 |
+
const finished = Date.now();
|
| 197 |
+
elapsed += finished - started;
|
| 198 |
+
}
|
| 199 |
+
},
|
| 200 |
+
warnIfExceeded() {
|
| 201 |
+
if (elapsed > maxDelay) {
|
| 202 |
+
console.warn(`${fnName} took ${elapsed}ms, which is more than the warning threshold of ${maxDelay}ms.
|
| 203 |
+
If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
|
| 204 |
+
It is disabled in production builds, so you don't need to worry about that.`);
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
};
|
| 208 |
+
}
|
| 209 |
+
var Tuple = class _Tuple extends Array {
|
| 210 |
+
constructor(...items) {
|
| 211 |
+
super(...items);
|
| 212 |
+
Object.setPrototypeOf(this, _Tuple.prototype);
|
| 213 |
+
}
|
| 214 |
+
static get [Symbol.species]() {
|
| 215 |
+
return _Tuple;
|
| 216 |
+
}
|
| 217 |
+
concat(...arr) {
|
| 218 |
+
return super.concat.apply(this, arr);
|
| 219 |
+
}
|
| 220 |
+
prepend(...arr) {
|
| 221 |
+
if (arr.length === 1 && Array.isArray(arr[0])) {
|
| 222 |
+
return new _Tuple(...arr[0].concat(this));
|
| 223 |
+
}
|
| 224 |
+
return new _Tuple(...arr.concat(this));
|
| 225 |
+
}
|
| 226 |
+
};
|
| 227 |
+
function freezeDraftable(val) {
|
| 228 |
+
return (0, import_immer2.isDraftable)(val) ? (0, import_immer2.produce)(val, () => {
|
| 229 |
+
}) : val;
|
| 230 |
+
}
|
| 231 |
+
function getOrInsertComputed(map, key, compute) {
|
| 232 |
+
if (map.has(key)) return map.get(key);
|
| 233 |
+
return map.set(key, compute(key)).get(key);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
// src/immutableStateInvariantMiddleware.ts
|
| 237 |
+
function isImmutableDefault(value) {
|
| 238 |
+
return typeof value !== "object" || value == null || Object.isFrozen(value);
|
| 239 |
+
}
|
| 240 |
+
function trackForMutations(isImmutable, ignorePaths, obj) {
|
| 241 |
+
const trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
|
| 242 |
+
return {
|
| 243 |
+
detectMutations() {
|
| 244 |
+
return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
|
| 245 |
+
}
|
| 246 |
+
};
|
| 247 |
+
}
|
| 248 |
+
function trackProperties(isImmutable, ignorePaths = [], obj, path = "", checkedObjects = /* @__PURE__ */ new Set()) {
|
| 249 |
+
const tracked = {
|
| 250 |
+
value: obj
|
| 251 |
+
};
|
| 252 |
+
if (!isImmutable(obj) && !checkedObjects.has(obj)) {
|
| 253 |
+
checkedObjects.add(obj);
|
| 254 |
+
tracked.children = {};
|
| 255 |
+
for (const key in obj) {
|
| 256 |
+
const childPath = path ? path + "." + key : key;
|
| 257 |
+
if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
|
| 258 |
+
continue;
|
| 259 |
+
}
|
| 260 |
+
tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
return tracked;
|
| 264 |
+
}
|
| 265 |
+
function detectMutations(isImmutable, ignoredPaths = [], trackedProperty, obj, sameParentRef = false, path = "") {
|
| 266 |
+
const prevObj = trackedProperty ? trackedProperty.value : void 0;
|
| 267 |
+
const sameRef = prevObj === obj;
|
| 268 |
+
if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
|
| 269 |
+
return {
|
| 270 |
+
wasMutated: true,
|
| 271 |
+
path
|
| 272 |
+
};
|
| 273 |
+
}
|
| 274 |
+
if (isImmutable(prevObj) || isImmutable(obj)) {
|
| 275 |
+
return {
|
| 276 |
+
wasMutated: false
|
| 277 |
+
};
|
| 278 |
+
}
|
| 279 |
+
const keysToDetect = {};
|
| 280 |
+
for (let key in trackedProperty.children) {
|
| 281 |
+
keysToDetect[key] = true;
|
| 282 |
+
}
|
| 283 |
+
for (let key in obj) {
|
| 284 |
+
keysToDetect[key] = true;
|
| 285 |
+
}
|
| 286 |
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
| 287 |
+
for (let key in keysToDetect) {
|
| 288 |
+
const nestedPath = path ? path + "." + key : key;
|
| 289 |
+
if (hasIgnoredPaths) {
|
| 290 |
+
const hasMatches = ignoredPaths.some((ignored) => {
|
| 291 |
+
if (ignored instanceof RegExp) {
|
| 292 |
+
return ignored.test(nestedPath);
|
| 293 |
+
}
|
| 294 |
+
return nestedPath === ignored;
|
| 295 |
+
});
|
| 296 |
+
if (hasMatches) {
|
| 297 |
+
continue;
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
const result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
|
| 301 |
+
if (result.wasMutated) {
|
| 302 |
+
return result;
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
return {
|
| 306 |
+
wasMutated: false
|
| 307 |
+
};
|
| 308 |
+
}
|
| 309 |
+
function createImmutableStateInvariantMiddleware(options = {}) {
|
| 310 |
+
if (false) {
|
| 311 |
+
return () => (next) => (action) => next(action);
|
| 312 |
+
} else {
|
| 313 |
+
let stringify2 = function(obj, serializer, indent, decycler) {
|
| 314 |
+
return JSON.stringify(obj, getSerialize2(serializer, decycler), indent);
|
| 315 |
+
}, getSerialize2 = function(serializer, decycler) {
|
| 316 |
+
let stack = [], keys = [];
|
| 317 |
+
if (!decycler) decycler = function(_, value) {
|
| 318 |
+
if (stack[0] === value) return "[Circular ~]";
|
| 319 |
+
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
|
| 320 |
+
};
|
| 321 |
+
return function(key, value) {
|
| 322 |
+
if (stack.length > 0) {
|
| 323 |
+
var thisPos = stack.indexOf(this);
|
| 324 |
+
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
| 325 |
+
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
| 326 |
+
if (~stack.indexOf(value)) value = decycler.call(this, key, value);
|
| 327 |
+
} else stack.push(value);
|
| 328 |
+
return serializer == null ? value : serializer.call(this, key, value);
|
| 329 |
+
};
|
| 330 |
+
};
|
| 331 |
+
var stringify = stringify2, getSerialize = getSerialize2;
|
| 332 |
+
let {
|
| 333 |
+
isImmutable = isImmutableDefault,
|
| 334 |
+
ignoredPaths,
|
| 335 |
+
warnAfter = 32
|
| 336 |
+
} = options;
|
| 337 |
+
const track = trackForMutations.bind(null, isImmutable, ignoredPaths);
|
| 338 |
+
return ({
|
| 339 |
+
getState
|
| 340 |
+
}) => {
|
| 341 |
+
let state = getState();
|
| 342 |
+
let tracker = track(state);
|
| 343 |
+
let result;
|
| 344 |
+
return (next) => (action) => {
|
| 345 |
+
const measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
|
| 346 |
+
measureUtils.measureTime(() => {
|
| 347 |
+
state = getState();
|
| 348 |
+
result = tracker.detectMutations();
|
| 349 |
+
tracker = track(state);
|
| 350 |
+
if (result.wasMutated) {
|
| 351 |
+
throw new Error(false ? _formatProdErrorMessage(19) : `A state mutation was detected between dispatches, in the path '${result.path || ""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);
|
| 352 |
+
}
|
| 353 |
+
});
|
| 354 |
+
const dispatchedAction = next(action);
|
| 355 |
+
measureUtils.measureTime(() => {
|
| 356 |
+
state = getState();
|
| 357 |
+
result = tracker.detectMutations();
|
| 358 |
+
tracker = track(state);
|
| 359 |
+
if (result.wasMutated) {
|
| 360 |
+
throw new Error(false ? _formatProdErrorMessage2(20) : `A state mutation was detected inside a dispatch, in the path: ${result.path || ""}. Take a look at the reducer(s) handling the action ${stringify2(action)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`);
|
| 361 |
+
}
|
| 362 |
+
});
|
| 363 |
+
measureUtils.warnIfExceeded();
|
| 364 |
+
return dispatchedAction;
|
| 365 |
+
};
|
| 366 |
+
};
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
// src/serializableStateInvariantMiddleware.ts
|
| 371 |
+
var import_redux3 = require("redux");
|
| 372 |
+
function isPlain(val) {
|
| 373 |
+
const type = typeof val;
|
| 374 |
+
return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || (0, import_redux3.isPlainObject)(val);
|
| 375 |
+
}
|
| 376 |
+
function findNonSerializableValue(value, path = "", isSerializable = isPlain, getEntries, ignoredPaths = [], cache) {
|
| 377 |
+
let foundNestedSerializable;
|
| 378 |
+
if (!isSerializable(value)) {
|
| 379 |
+
return {
|
| 380 |
+
keyPath: path || "<root>",
|
| 381 |
+
value
|
| 382 |
+
};
|
| 383 |
+
}
|
| 384 |
+
if (typeof value !== "object" || value === null) {
|
| 385 |
+
return false;
|
| 386 |
+
}
|
| 387 |
+
if (cache?.has(value)) return false;
|
| 388 |
+
const entries = getEntries != null ? getEntries(value) : Object.entries(value);
|
| 389 |
+
const hasIgnoredPaths = ignoredPaths.length > 0;
|
| 390 |
+
for (const [key, nestedValue] of entries) {
|
| 391 |
+
const nestedPath = path ? path + "." + key : key;
|
| 392 |
+
if (hasIgnoredPaths) {
|
| 393 |
+
const hasMatches = ignoredPaths.some((ignored) => {
|
| 394 |
+
if (ignored instanceof RegExp) {
|
| 395 |
+
return ignored.test(nestedPath);
|
| 396 |
+
}
|
| 397 |
+
return nestedPath === ignored;
|
| 398 |
+
});
|
| 399 |
+
if (hasMatches) {
|
| 400 |
+
continue;
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
if (!isSerializable(nestedValue)) {
|
| 404 |
+
return {
|
| 405 |
+
keyPath: nestedPath,
|
| 406 |
+
value: nestedValue
|
| 407 |
+
};
|
| 408 |
+
}
|
| 409 |
+
if (typeof nestedValue === "object") {
|
| 410 |
+
foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
|
| 411 |
+
if (foundNestedSerializable) {
|
| 412 |
+
return foundNestedSerializable;
|
| 413 |
+
}
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
if (cache && isNestedFrozen(value)) cache.add(value);
|
| 417 |
+
return false;
|
| 418 |
+
}
|
| 419 |
+
function isNestedFrozen(value) {
|
| 420 |
+
if (!Object.isFrozen(value)) return false;
|
| 421 |
+
for (const nestedValue of Object.values(value)) {
|
| 422 |
+
if (typeof nestedValue !== "object" || nestedValue === null) continue;
|
| 423 |
+
if (!isNestedFrozen(nestedValue)) return false;
|
| 424 |
+
}
|
| 425 |
+
return true;
|
| 426 |
+
}
|
| 427 |
+
function createSerializableStateInvariantMiddleware(options = {}) {
|
| 428 |
+
if (false) {
|
| 429 |
+
return () => (next) => (action) => next(action);
|
| 430 |
+
} else {
|
| 431 |
+
const {
|
| 432 |
+
isSerializable = isPlain,
|
| 433 |
+
getEntries,
|
| 434 |
+
ignoredActions = [],
|
| 435 |
+
ignoredActionPaths = ["meta.arg", "meta.baseQueryMeta"],
|
| 436 |
+
ignoredPaths = [],
|
| 437 |
+
warnAfter = 32,
|
| 438 |
+
ignoreState = false,
|
| 439 |
+
ignoreActions = false,
|
| 440 |
+
disableCache = false
|
| 441 |
+
} = options;
|
| 442 |
+
const cache = !disableCache && WeakSet ? /* @__PURE__ */ new WeakSet() : void 0;
|
| 443 |
+
return (storeAPI) => (next) => (action) => {
|
| 444 |
+
if (!(0, import_redux3.isAction)(action)) {
|
| 445 |
+
return next(action);
|
| 446 |
+
}
|
| 447 |
+
const result = next(action);
|
| 448 |
+
const measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
|
| 449 |
+
if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
|
| 450 |
+
measureUtils.measureTime(() => {
|
| 451 |
+
const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
|
| 452 |
+
if (foundActionNonSerializableValue) {
|
| 453 |
+
const {
|
| 454 |
+
keyPath,
|
| 455 |
+
value
|
| 456 |
+
} = foundActionNonSerializableValue;
|
| 457 |
+
console.error(`A non-serializable value was detected in an action, in the path: \`${keyPath}\`. Value:`, value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
|
| 458 |
+
}
|
| 459 |
+
});
|
| 460 |
+
}
|
| 461 |
+
if (!ignoreState) {
|
| 462 |
+
measureUtils.measureTime(() => {
|
| 463 |
+
const state = storeAPI.getState();
|
| 464 |
+
const foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
|
| 465 |
+
if (foundStateNonSerializableValue) {
|
| 466 |
+
const {
|
| 467 |
+
keyPath,
|
| 468 |
+
value
|
| 469 |
+
} = foundStateNonSerializableValue;
|
| 470 |
+
console.error(`A non-serializable value was detected in the state, in the path: \`${keyPath}\`. Value:`, value, `
|
| 471 |
+
Take a look at the reducer(s) handling this action type: ${action.type}.
|
| 472 |
+
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`);
|
| 473 |
+
}
|
| 474 |
+
});
|
| 475 |
+
measureUtils.warnIfExceeded();
|
| 476 |
+
}
|
| 477 |
+
return result;
|
| 478 |
+
};
|
| 479 |
+
}
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
// src/getDefaultMiddleware.ts
|
| 483 |
+
function isBoolean(x) {
|
| 484 |
+
return typeof x === "boolean";
|
| 485 |
+
}
|
| 486 |
+
var buildGetDefaultMiddleware = () => function getDefaultMiddleware(options) {
|
| 487 |
+
const {
|
| 488 |
+
thunk = true,
|
| 489 |
+
immutableCheck = true,
|
| 490 |
+
serializableCheck = true,
|
| 491 |
+
actionCreatorCheck = true
|
| 492 |
+
} = options ?? {};
|
| 493 |
+
let middlewareArray = new Tuple();
|
| 494 |
+
if (thunk) {
|
| 495 |
+
if (isBoolean(thunk)) {
|
| 496 |
+
middlewareArray.push(import_redux_thunk.thunk);
|
| 497 |
+
} else {
|
| 498 |
+
middlewareArray.push((0, import_redux_thunk.withExtraArgument)(thunk.extraArgument));
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
if (true) {
|
| 502 |
+
if (immutableCheck) {
|
| 503 |
+
let immutableOptions = {};
|
| 504 |
+
if (!isBoolean(immutableCheck)) {
|
| 505 |
+
immutableOptions = immutableCheck;
|
| 506 |
+
}
|
| 507 |
+
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
|
| 508 |
+
}
|
| 509 |
+
if (serializableCheck) {
|
| 510 |
+
let serializableOptions = {};
|
| 511 |
+
if (!isBoolean(serializableCheck)) {
|
| 512 |
+
serializableOptions = serializableCheck;
|
| 513 |
+
}
|
| 514 |
+
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
|
| 515 |
+
}
|
| 516 |
+
if (actionCreatorCheck) {
|
| 517 |
+
let actionCreatorOptions = {};
|
| 518 |
+
if (!isBoolean(actionCreatorCheck)) {
|
| 519 |
+
actionCreatorOptions = actionCreatorCheck;
|
| 520 |
+
}
|
| 521 |
+
middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
|
| 522 |
+
}
|
| 523 |
+
}
|
| 524 |
+
return middlewareArray;
|
| 525 |
+
};
|
| 526 |
+
|
| 527 |
+
// src/autoBatchEnhancer.ts
|
| 528 |
+
var SHOULD_AUTOBATCH = "RTK_autoBatch";
|
| 529 |
+
var prepareAutoBatched = () => (payload) => ({
|
| 530 |
+
payload,
|
| 531 |
+
meta: {
|
| 532 |
+
[SHOULD_AUTOBATCH]: true
|
| 533 |
+
}
|
| 534 |
+
});
|
| 535 |
+
var createQueueWithTimer = (timeout) => {
|
| 536 |
+
return (notify) => {
|
| 537 |
+
setTimeout(notify, timeout);
|
| 538 |
+
};
|
| 539 |
+
};
|
| 540 |
+
var autoBatchEnhancer = (options = {
|
| 541 |
+
type: "raf"
|
| 542 |
+
}) => (next) => (...args) => {
|
| 543 |
+
const store = next(...args);
|
| 544 |
+
let notifying = true;
|
| 545 |
+
let shouldNotifyAtEndOfTick = false;
|
| 546 |
+
let notificationQueued = false;
|
| 547 |
+
const listeners = /* @__PURE__ */ new Set();
|
| 548 |
+
const queueCallback = options.type === "tick" ? queueMicrotask : options.type === "raf" ? (
|
| 549 |
+
// requestAnimationFrame won't exist in SSR environments. Fall back to a vague approximation just to keep from erroring.
|
| 550 |
+
typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10)
|
| 551 |
+
) : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
|
| 552 |
+
const notifyListeners = () => {
|
| 553 |
+
notificationQueued = false;
|
| 554 |
+
if (shouldNotifyAtEndOfTick) {
|
| 555 |
+
shouldNotifyAtEndOfTick = false;
|
| 556 |
+
listeners.forEach((l) => l());
|
| 557 |
+
}
|
| 558 |
+
};
|
| 559 |
+
return Object.assign({}, store, {
|
| 560 |
+
// Override the base `store.subscribe` method to keep original listeners
|
| 561 |
+
// from running if we're delaying notifications
|
| 562 |
+
subscribe(listener2) {
|
| 563 |
+
const wrappedListener = () => notifying && listener2();
|
| 564 |
+
const unsubscribe = store.subscribe(wrappedListener);
|
| 565 |
+
listeners.add(listener2);
|
| 566 |
+
return () => {
|
| 567 |
+
unsubscribe();
|
| 568 |
+
listeners.delete(listener2);
|
| 569 |
+
};
|
| 570 |
+
},
|
| 571 |
+
// Override the base `store.dispatch` method so that we can check actions
|
| 572 |
+
// for the `shouldAutoBatch` flag and determine if batching is active
|
| 573 |
+
dispatch(action) {
|
| 574 |
+
try {
|
| 575 |
+
notifying = !action?.meta?.[SHOULD_AUTOBATCH];
|
| 576 |
+
shouldNotifyAtEndOfTick = !notifying;
|
| 577 |
+
if (shouldNotifyAtEndOfTick) {
|
| 578 |
+
if (!notificationQueued) {
|
| 579 |
+
notificationQueued = true;
|
| 580 |
+
queueCallback(notifyListeners);
|
| 581 |
+
}
|
| 582 |
+
}
|
| 583 |
+
return store.dispatch(action);
|
| 584 |
+
} finally {
|
| 585 |
+
notifying = true;
|
| 586 |
+
}
|
| 587 |
+
}
|
| 588 |
+
});
|
| 589 |
+
};
|
| 590 |
+
|
| 591 |
+
// src/getDefaultEnhancers.ts
|
| 592 |
+
var buildGetDefaultEnhancers = (middlewareEnhancer) => function getDefaultEnhancers(options) {
|
| 593 |
+
const {
|
| 594 |
+
autoBatch = true
|
| 595 |
+
} = options ?? {};
|
| 596 |
+
let enhancerArray = new Tuple(middlewareEnhancer);
|
| 597 |
+
if (autoBatch) {
|
| 598 |
+
enhancerArray.push(autoBatchEnhancer(typeof autoBatch === "object" ? autoBatch : void 0));
|
| 599 |
+
}
|
| 600 |
+
return enhancerArray;
|
| 601 |
+
};
|
| 602 |
+
|
| 603 |
+
// src/configureStore.ts
|
| 604 |
+
function configureStore(options) {
|
| 605 |
+
const getDefaultMiddleware = buildGetDefaultMiddleware();
|
| 606 |
+
const {
|
| 607 |
+
reducer = void 0,
|
| 608 |
+
middleware,
|
| 609 |
+
devTools = true,
|
| 610 |
+
duplicateMiddlewareCheck = true,
|
| 611 |
+
preloadedState = void 0,
|
| 612 |
+
enhancers = void 0
|
| 613 |
+
} = options || {};
|
| 614 |
+
let rootReducer;
|
| 615 |
+
if (typeof reducer === "function") {
|
| 616 |
+
rootReducer = reducer;
|
| 617 |
+
} else if ((0, import_redux4.isPlainObject)(reducer)) {
|
| 618 |
+
rootReducer = (0, import_redux4.combineReducers)(reducer);
|
| 619 |
+
} else {
|
| 620 |
+
throw new Error(false ? _formatProdErrorMessage(1) : "`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");
|
| 621 |
+
}
|
| 622 |
+
if (middleware && typeof middleware !== "function") {
|
| 623 |
+
throw new Error(false ? _formatProdErrorMessage2(2) : "`middleware` field must be a callback");
|
| 624 |
+
}
|
| 625 |
+
let finalMiddleware;
|
| 626 |
+
if (typeof middleware === "function") {
|
| 627 |
+
finalMiddleware = middleware(getDefaultMiddleware);
|
| 628 |
+
if (!Array.isArray(finalMiddleware)) {
|
| 629 |
+
throw new Error(false ? _formatProdErrorMessage3(3) : "when using a middleware builder function, an array of middleware must be returned");
|
| 630 |
+
}
|
| 631 |
+
} else {
|
| 632 |
+
finalMiddleware = getDefaultMiddleware();
|
| 633 |
+
}
|
| 634 |
+
if (finalMiddleware.some((item) => typeof item !== "function")) {
|
| 635 |
+
throw new Error(false ? _formatProdErrorMessage4(4) : "each middleware provided to configureStore must be a function");
|
| 636 |
+
}
|
| 637 |
+
if (duplicateMiddlewareCheck) {
|
| 638 |
+
let middlewareReferences = /* @__PURE__ */ new Set();
|
| 639 |
+
finalMiddleware.forEach((middleware2) => {
|
| 640 |
+
if (middlewareReferences.has(middleware2)) {
|
| 641 |
+
throw new Error(false ? _formatProdErrorMessage5(42) : "Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");
|
| 642 |
+
}
|
| 643 |
+
middlewareReferences.add(middleware2);
|
| 644 |
+
});
|
| 645 |
+
}
|
| 646 |
+
let finalCompose = import_redux4.compose;
|
| 647 |
+
if (devTools) {
|
| 648 |
+
finalCompose = composeWithDevTools({
|
| 649 |
+
// Enable capture of stack traces for dispatched Redux actions
|
| 650 |
+
trace: true,
|
| 651 |
+
...typeof devTools === "object" && devTools
|
| 652 |
+
});
|
| 653 |
+
}
|
| 654 |
+
const middlewareEnhancer = (0, import_redux4.applyMiddleware)(...finalMiddleware);
|
| 655 |
+
const getDefaultEnhancers = buildGetDefaultEnhancers(middlewareEnhancer);
|
| 656 |
+
if (enhancers && typeof enhancers !== "function") {
|
| 657 |
+
throw new Error(false ? _formatProdErrorMessage6(5) : "`enhancers` field must be a callback");
|
| 658 |
+
}
|
| 659 |
+
let storeEnhancers = typeof enhancers === "function" ? enhancers(getDefaultEnhancers) : getDefaultEnhancers();
|
| 660 |
+
if (!Array.isArray(storeEnhancers)) {
|
| 661 |
+
throw new Error(false ? _formatProdErrorMessage7(6) : "`enhancers` callback must return an array");
|
| 662 |
+
}
|
| 663 |
+
if (storeEnhancers.some((item) => typeof item !== "function")) {
|
| 664 |
+
throw new Error(false ? _formatProdErrorMessage8(7) : "each enhancer provided to configureStore must be a function");
|
| 665 |
+
}
|
| 666 |
+
if (finalMiddleware.length && !storeEnhancers.includes(middlewareEnhancer)) {
|
| 667 |
+
console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");
|
| 668 |
+
}
|
| 669 |
+
const composedEnhancer = finalCompose(...storeEnhancers);
|
| 670 |
+
return (0, import_redux4.createStore)(rootReducer, preloadedState, composedEnhancer);
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
// src/createReducer.ts
|
| 674 |
+
var import_immer3 = require("immer");
|
| 675 |
+
|
| 676 |
+
// src/mapBuilders.ts
|
| 677 |
+
function executeReducerBuilderCallback(builderCallback) {
|
| 678 |
+
const actionsMap = {};
|
| 679 |
+
const actionMatchers = [];
|
| 680 |
+
let defaultCaseReducer;
|
| 681 |
+
const builder = {
|
| 682 |
+
addCase(typeOrActionCreator, reducer) {
|
| 683 |
+
if (true) {
|
| 684 |
+
if (actionMatchers.length > 0) {
|
| 685 |
+
throw new Error(false ? _formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
|
| 686 |
+
}
|
| 687 |
+
if (defaultCaseReducer) {
|
| 688 |
+
throw new Error(false ? _formatProdErrorMessage2(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
| 689 |
+
}
|
| 690 |
+
}
|
| 691 |
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
| 692 |
+
if (!type) {
|
| 693 |
+
throw new Error(false ? _formatProdErrorMessage3(28) : "`builder.addCase` cannot be called with an empty action type");
|
| 694 |
+
}
|
| 695 |
+
if (type in actionsMap) {
|
| 696 |
+
throw new Error(false ? _formatProdErrorMessage4(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
| 697 |
+
}
|
| 698 |
+
actionsMap[type] = reducer;
|
| 699 |
+
return builder;
|
| 700 |
+
},
|
| 701 |
+
addMatcher(matcher, reducer) {
|
| 702 |
+
if (true) {
|
| 703 |
+
if (defaultCaseReducer) {
|
| 704 |
+
throw new Error(false ? _formatProdErrorMessage5(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
| 705 |
+
}
|
| 706 |
+
}
|
| 707 |
+
actionMatchers.push({
|
| 708 |
+
matcher,
|
| 709 |
+
reducer
|
| 710 |
+
});
|
| 711 |
+
return builder;
|
| 712 |
+
},
|
| 713 |
+
addDefaultCase(reducer) {
|
| 714 |
+
if (true) {
|
| 715 |
+
if (defaultCaseReducer) {
|
| 716 |
+
throw new Error(false ? _formatProdErrorMessage6(31) : "`builder.addDefaultCase` can only be called once");
|
| 717 |
+
}
|
| 718 |
+
}
|
| 719 |
+
defaultCaseReducer = reducer;
|
| 720 |
+
return builder;
|
| 721 |
+
}
|
| 722 |
+
};
|
| 723 |
+
builderCallback(builder);
|
| 724 |
+
return [actionsMap, actionMatchers, defaultCaseReducer];
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
// src/createReducer.ts
|
| 728 |
+
function isStateFunction(x) {
|
| 729 |
+
return typeof x === "function";
|
| 730 |
+
}
|
| 731 |
+
function createReducer(initialState, mapOrBuilderCallback) {
|
| 732 |
+
if (true) {
|
| 733 |
+
if (typeof mapOrBuilderCallback === "object") {
|
| 734 |
+
throw new Error(false ? _formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
|
| 735 |
+
}
|
| 736 |
+
}
|
| 737 |
+
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
|
| 738 |
+
let getInitialState;
|
| 739 |
+
if (isStateFunction(initialState)) {
|
| 740 |
+
getInitialState = () => freezeDraftable(initialState());
|
| 741 |
+
} else {
|
| 742 |
+
const frozenInitialState = freezeDraftable(initialState);
|
| 743 |
+
getInitialState = () => frozenInitialState;
|
| 744 |
+
}
|
| 745 |
+
function reducer(state = getInitialState(), action) {
|
| 746 |
+
let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
|
| 747 |
+
matcher
|
| 748 |
+
}) => matcher(action)).map(({
|
| 749 |
+
reducer: reducer2
|
| 750 |
+
}) => reducer2)];
|
| 751 |
+
if (caseReducers.filter((cr) => !!cr).length === 0) {
|
| 752 |
+
caseReducers = [finalDefaultCaseReducer];
|
| 753 |
+
}
|
| 754 |
+
return caseReducers.reduce((previousState, caseReducer) => {
|
| 755 |
+
if (caseReducer) {
|
| 756 |
+
if ((0, import_immer3.isDraft)(previousState)) {
|
| 757 |
+
const draft = previousState;
|
| 758 |
+
const result = caseReducer(draft, action);
|
| 759 |
+
if (result === void 0) {
|
| 760 |
+
return previousState;
|
| 761 |
+
}
|
| 762 |
+
return result;
|
| 763 |
+
} else if (!(0, import_immer3.isDraftable)(previousState)) {
|
| 764 |
+
const result = caseReducer(previousState, action);
|
| 765 |
+
if (result === void 0) {
|
| 766 |
+
if (previousState === null) {
|
| 767 |
+
return previousState;
|
| 768 |
+
}
|
| 769 |
+
throw Error("A case reducer on a non-draftable value must not return undefined");
|
| 770 |
+
}
|
| 771 |
+
return result;
|
| 772 |
+
} else {
|
| 773 |
+
return (0, import_immer3.produce)(previousState, (draft) => {
|
| 774 |
+
return caseReducer(draft, action);
|
| 775 |
+
});
|
| 776 |
+
}
|
| 777 |
+
}
|
| 778 |
+
return previousState;
|
| 779 |
+
}, state);
|
| 780 |
+
}
|
| 781 |
+
reducer.getInitialState = getInitialState;
|
| 782 |
+
return reducer;
|
| 783 |
+
}
|
| 784 |
+
|
| 785 |
+
// src/matchers.ts
|
| 786 |
+
var matches = (matcher, action) => {
|
| 787 |
+
if (hasMatchFunction(matcher)) {
|
| 788 |
+
return matcher.match(action);
|
| 789 |
+
} else {
|
| 790 |
+
return matcher(action);
|
| 791 |
+
}
|
| 792 |
+
};
|
| 793 |
+
function isAnyOf(...matchers) {
|
| 794 |
+
return (action) => {
|
| 795 |
+
return matchers.some((matcher) => matches(matcher, action));
|
| 796 |
+
};
|
| 797 |
+
}
|
| 798 |
+
function isAllOf(...matchers) {
|
| 799 |
+
return (action) => {
|
| 800 |
+
return matchers.every((matcher) => matches(matcher, action));
|
| 801 |
+
};
|
| 802 |
+
}
|
| 803 |
+
function hasExpectedRequestMetadata(action, validStatus) {
|
| 804 |
+
if (!action || !action.meta) return false;
|
| 805 |
+
const hasValidRequestId = typeof action.meta.requestId === "string";
|
| 806 |
+
const hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
|
| 807 |
+
return hasValidRequestId && hasValidRequestStatus;
|
| 808 |
+
}
|
| 809 |
+
function isAsyncThunkArray(a) {
|
| 810 |
+
return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
|
| 811 |
+
}
|
| 812 |
+
function isPending(...asyncThunks) {
|
| 813 |
+
if (asyncThunks.length === 0) {
|
| 814 |
+
return (action) => hasExpectedRequestMetadata(action, ["pending"]);
|
| 815 |
+
}
|
| 816 |
+
if (!isAsyncThunkArray(asyncThunks)) {
|
| 817 |
+
return isPending()(asyncThunks[0]);
|
| 818 |
+
}
|
| 819 |
+
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.pending));
|
| 820 |
+
}
|
| 821 |
+
function isRejected(...asyncThunks) {
|
| 822 |
+
if (asyncThunks.length === 0) {
|
| 823 |
+
return (action) => hasExpectedRequestMetadata(action, ["rejected"]);
|
| 824 |
+
}
|
| 825 |
+
if (!isAsyncThunkArray(asyncThunks)) {
|
| 826 |
+
return isRejected()(asyncThunks[0]);
|
| 827 |
+
}
|
| 828 |
+
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.rejected));
|
| 829 |
+
}
|
| 830 |
+
function isRejectedWithValue(...asyncThunks) {
|
| 831 |
+
const hasFlag = (action) => {
|
| 832 |
+
return action && action.meta && action.meta.rejectedWithValue;
|
| 833 |
+
};
|
| 834 |
+
if (asyncThunks.length === 0) {
|
| 835 |
+
return isAllOf(isRejected(...asyncThunks), hasFlag);
|
| 836 |
+
}
|
| 837 |
+
if (!isAsyncThunkArray(asyncThunks)) {
|
| 838 |
+
return isRejectedWithValue()(asyncThunks[0]);
|
| 839 |
+
}
|
| 840 |
+
return isAllOf(isRejected(...asyncThunks), hasFlag);
|
| 841 |
+
}
|
| 842 |
+
function isFulfilled(...asyncThunks) {
|
| 843 |
+
if (asyncThunks.length === 0) {
|
| 844 |
+
return (action) => hasExpectedRequestMetadata(action, ["fulfilled"]);
|
| 845 |
+
}
|
| 846 |
+
if (!isAsyncThunkArray(asyncThunks)) {
|
| 847 |
+
return isFulfilled()(asyncThunks[0]);
|
| 848 |
+
}
|
| 849 |
+
return isAnyOf(...asyncThunks.map((asyncThunk) => asyncThunk.fulfilled));
|
| 850 |
+
}
|
| 851 |
+
function isAsyncThunkAction(...asyncThunks) {
|
| 852 |
+
if (asyncThunks.length === 0) {
|
| 853 |
+
return (action) => hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]);
|
| 854 |
+
}
|
| 855 |
+
if (!isAsyncThunkArray(asyncThunks)) {
|
| 856 |
+
return isAsyncThunkAction()(asyncThunks[0]);
|
| 857 |
+
}
|
| 858 |
+
return isAnyOf(...asyncThunks.flatMap((asyncThunk) => [asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled]));
|
| 859 |
+
}
|
| 860 |
+
|
| 861 |
+
// src/nanoid.ts
|
| 862 |
+
var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
|
| 863 |
+
var nanoid = (size = 21) => {
|
| 864 |
+
let id = "";
|
| 865 |
+
let i = size;
|
| 866 |
+
while (i--) {
|
| 867 |
+
id += urlAlphabet[Math.random() * 64 | 0];
|
| 868 |
+
}
|
| 869 |
+
return id;
|
| 870 |
+
};
|
| 871 |
+
|
| 872 |
+
// src/createAsyncThunk.ts
|
| 873 |
+
var commonProperties = ["name", "message", "stack", "code"];
|
| 874 |
+
var RejectWithValue = class {
|
| 875 |
+
constructor(payload, meta) {
|
| 876 |
+
this.payload = payload;
|
| 877 |
+
this.meta = meta;
|
| 878 |
+
}
|
| 879 |
+
/*
|
| 880 |
+
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
| 881 |
+
does not exist at runtime
|
| 882 |
+
*/
|
| 883 |
+
_type;
|
| 884 |
+
};
|
| 885 |
+
var FulfillWithMeta = class {
|
| 886 |
+
constructor(payload, meta) {
|
| 887 |
+
this.payload = payload;
|
| 888 |
+
this.meta = meta;
|
| 889 |
+
}
|
| 890 |
+
/*
|
| 891 |
+
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
| 892 |
+
does not exist at runtime
|
| 893 |
+
*/
|
| 894 |
+
_type;
|
| 895 |
+
};
|
| 896 |
+
var miniSerializeError = (value) => {
|
| 897 |
+
if (typeof value === "object" && value !== null) {
|
| 898 |
+
const simpleError = {};
|
| 899 |
+
for (const property of commonProperties) {
|
| 900 |
+
if (typeof value[property] === "string") {
|
| 901 |
+
simpleError[property] = value[property];
|
| 902 |
+
}
|
| 903 |
+
}
|
| 904 |
+
return simpleError;
|
| 905 |
+
}
|
| 906 |
+
return {
|
| 907 |
+
message: String(value)
|
| 908 |
+
};
|
| 909 |
+
};
|
| 910 |
+
var externalAbortMessage = "External signal was aborted";
|
| 911 |
+
var createAsyncThunk = /* @__PURE__ */ (() => {
|
| 912 |
+
function createAsyncThunk2(typePrefix, payloadCreator, options) {
|
| 913 |
+
const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
|
| 914 |
+
payload,
|
| 915 |
+
meta: {
|
| 916 |
+
...meta || {},
|
| 917 |
+
arg,
|
| 918 |
+
requestId,
|
| 919 |
+
requestStatus: "fulfilled"
|
| 920 |
+
}
|
| 921 |
+
}));
|
| 922 |
+
const pending = createAction(typePrefix + "/pending", (requestId, arg, meta) => ({
|
| 923 |
+
payload: void 0,
|
| 924 |
+
meta: {
|
| 925 |
+
...meta || {},
|
| 926 |
+
arg,
|
| 927 |
+
requestId,
|
| 928 |
+
requestStatus: "pending"
|
| 929 |
+
}
|
| 930 |
+
}));
|
| 931 |
+
const rejected = createAction(typePrefix + "/rejected", (error, requestId, arg, payload, meta) => ({
|
| 932 |
+
payload,
|
| 933 |
+
error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
|
| 934 |
+
meta: {
|
| 935 |
+
...meta || {},
|
| 936 |
+
arg,
|
| 937 |
+
requestId,
|
| 938 |
+
rejectedWithValue: !!payload,
|
| 939 |
+
requestStatus: "rejected",
|
| 940 |
+
aborted: error?.name === "AbortError",
|
| 941 |
+
condition: error?.name === "ConditionError"
|
| 942 |
+
}
|
| 943 |
+
}));
|
| 944 |
+
function actionCreator(arg, {
|
| 945 |
+
signal
|
| 946 |
+
} = {}) {
|
| 947 |
+
return (dispatch, getState, extra) => {
|
| 948 |
+
const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
|
| 949 |
+
const abortController = new AbortController();
|
| 950 |
+
let abortHandler;
|
| 951 |
+
let abortReason;
|
| 952 |
+
function abort(reason) {
|
| 953 |
+
abortReason = reason;
|
| 954 |
+
abortController.abort();
|
| 955 |
+
}
|
| 956 |
+
if (signal) {
|
| 957 |
+
if (signal.aborted) {
|
| 958 |
+
abort(externalAbortMessage);
|
| 959 |
+
} else {
|
| 960 |
+
signal.addEventListener("abort", () => abort(externalAbortMessage), {
|
| 961 |
+
once: true
|
| 962 |
+
});
|
| 963 |
+
}
|
| 964 |
+
}
|
| 965 |
+
const promise = async function() {
|
| 966 |
+
let finalAction;
|
| 967 |
+
try {
|
| 968 |
+
let conditionResult = options?.condition?.(arg, {
|
| 969 |
+
getState,
|
| 970 |
+
extra
|
| 971 |
+
});
|
| 972 |
+
if (isThenable(conditionResult)) {
|
| 973 |
+
conditionResult = await conditionResult;
|
| 974 |
+
}
|
| 975 |
+
if (conditionResult === false || abortController.signal.aborted) {
|
| 976 |
+
throw {
|
| 977 |
+
name: "ConditionError",
|
| 978 |
+
message: "Aborted due to condition callback returning false."
|
| 979 |
+
};
|
| 980 |
+
}
|
| 981 |
+
const abortedPromise = new Promise((_, reject) => {
|
| 982 |
+
abortHandler = () => {
|
| 983 |
+
reject({
|
| 984 |
+
name: "AbortError",
|
| 985 |
+
message: abortReason || "Aborted"
|
| 986 |
+
});
|
| 987 |
+
};
|
| 988 |
+
abortController.signal.addEventListener("abort", abortHandler);
|
| 989 |
+
});
|
| 990 |
+
dispatch(pending(requestId, arg, options?.getPendingMeta?.({
|
| 991 |
+
requestId,
|
| 992 |
+
arg
|
| 993 |
+
}, {
|
| 994 |
+
getState,
|
| 995 |
+
extra
|
| 996 |
+
})));
|
| 997 |
+
finalAction = await Promise.race([abortedPromise, Promise.resolve(payloadCreator(arg, {
|
| 998 |
+
dispatch,
|
| 999 |
+
getState,
|
| 1000 |
+
extra,
|
| 1001 |
+
requestId,
|
| 1002 |
+
signal: abortController.signal,
|
| 1003 |
+
abort,
|
| 1004 |
+
rejectWithValue: (value, meta) => {
|
| 1005 |
+
return new RejectWithValue(value, meta);
|
| 1006 |
+
},
|
| 1007 |
+
fulfillWithValue: (value, meta) => {
|
| 1008 |
+
return new FulfillWithMeta(value, meta);
|
| 1009 |
+
}
|
| 1010 |
+
})).then((result) => {
|
| 1011 |
+
if (result instanceof RejectWithValue) {
|
| 1012 |
+
throw result;
|
| 1013 |
+
}
|
| 1014 |
+
if (result instanceof FulfillWithMeta) {
|
| 1015 |
+
return fulfilled(result.payload, requestId, arg, result.meta);
|
| 1016 |
+
}
|
| 1017 |
+
return fulfilled(result, requestId, arg);
|
| 1018 |
+
})]);
|
| 1019 |
+
} catch (err) {
|
| 1020 |
+
finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
|
| 1021 |
+
} finally {
|
| 1022 |
+
if (abortHandler) {
|
| 1023 |
+
abortController.signal.removeEventListener("abort", abortHandler);
|
| 1024 |
+
}
|
| 1025 |
+
}
|
| 1026 |
+
const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
|
| 1027 |
+
if (!skipDispatch) {
|
| 1028 |
+
dispatch(finalAction);
|
| 1029 |
+
}
|
| 1030 |
+
return finalAction;
|
| 1031 |
+
}();
|
| 1032 |
+
return Object.assign(promise, {
|
| 1033 |
+
abort,
|
| 1034 |
+
requestId,
|
| 1035 |
+
arg,
|
| 1036 |
+
unwrap() {
|
| 1037 |
+
return promise.then(unwrapResult);
|
| 1038 |
+
}
|
| 1039 |
+
});
|
| 1040 |
+
};
|
| 1041 |
+
}
|
| 1042 |
+
return Object.assign(actionCreator, {
|
| 1043 |
+
pending,
|
| 1044 |
+
rejected,
|
| 1045 |
+
fulfilled,
|
| 1046 |
+
settled: isAnyOf(rejected, fulfilled),
|
| 1047 |
+
typePrefix
|
| 1048 |
+
});
|
| 1049 |
+
}
|
| 1050 |
+
createAsyncThunk2.withTypes = () => createAsyncThunk2;
|
| 1051 |
+
return createAsyncThunk2;
|
| 1052 |
+
})();
|
| 1053 |
+
function unwrapResult(action) {
|
| 1054 |
+
if (action.meta && action.meta.rejectedWithValue) {
|
| 1055 |
+
throw action.payload;
|
| 1056 |
+
}
|
| 1057 |
+
if (action.error) {
|
| 1058 |
+
throw action.error;
|
| 1059 |
+
}
|
| 1060 |
+
return action.payload;
|
| 1061 |
+
}
|
| 1062 |
+
function isThenable(value) {
|
| 1063 |
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
| 1064 |
+
}
|
| 1065 |
+
|
| 1066 |
+
// src/createSlice.ts
|
| 1067 |
+
var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
|
| 1068 |
+
var asyncThunkCreator = {
|
| 1069 |
+
[asyncThunkSymbol]: createAsyncThunk
|
| 1070 |
+
};
|
| 1071 |
+
var ReducerType = /* @__PURE__ */ ((ReducerType2) => {
|
| 1072 |
+
ReducerType2["reducer"] = "reducer";
|
| 1073 |
+
ReducerType2["reducerWithPrepare"] = "reducerWithPrepare";
|
| 1074 |
+
ReducerType2["asyncThunk"] = "asyncThunk";
|
| 1075 |
+
return ReducerType2;
|
| 1076 |
+
})(ReducerType || {});
|
| 1077 |
+
function getType(slice, actionKey) {
|
| 1078 |
+
return `${slice}/${actionKey}`;
|
| 1079 |
+
}
|
| 1080 |
+
function buildCreateSlice({
|
| 1081 |
+
creators
|
| 1082 |
+
} = {}) {
|
| 1083 |
+
const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
|
| 1084 |
+
return function createSlice2(options) {
|
| 1085 |
+
const {
|
| 1086 |
+
name,
|
| 1087 |
+
reducerPath = name
|
| 1088 |
+
} = options;
|
| 1089 |
+
if (!name) {
|
| 1090 |
+
throw new Error(false ? _formatProdErrorMessage(11) : "`name` is a required option for createSlice");
|
| 1091 |
+
}
|
| 1092 |
+
if (typeof process !== "undefined" && true) {
|
| 1093 |
+
if (options.initialState === void 0) {
|
| 1094 |
+
console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
| 1095 |
+
}
|
| 1096 |
+
}
|
| 1097 |
+
const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
|
| 1098 |
+
const reducerNames = Object.keys(reducers);
|
| 1099 |
+
const context = {
|
| 1100 |
+
sliceCaseReducersByName: {},
|
| 1101 |
+
sliceCaseReducersByType: {},
|
| 1102 |
+
actionCreators: {},
|
| 1103 |
+
sliceMatchers: []
|
| 1104 |
+
};
|
| 1105 |
+
const contextMethods = {
|
| 1106 |
+
addCase(typeOrActionCreator, reducer2) {
|
| 1107 |
+
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
| 1108 |
+
if (!type) {
|
| 1109 |
+
throw new Error(false ? _formatProdErrorMessage2(12) : "`context.addCase` cannot be called with an empty action type");
|
| 1110 |
+
}
|
| 1111 |
+
if (type in context.sliceCaseReducersByType) {
|
| 1112 |
+
throw new Error(false ? _formatProdErrorMessage3(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
|
| 1113 |
+
}
|
| 1114 |
+
context.sliceCaseReducersByType[type] = reducer2;
|
| 1115 |
+
return contextMethods;
|
| 1116 |
+
},
|
| 1117 |
+
addMatcher(matcher, reducer2) {
|
| 1118 |
+
context.sliceMatchers.push({
|
| 1119 |
+
matcher,
|
| 1120 |
+
reducer: reducer2
|
| 1121 |
+
});
|
| 1122 |
+
return contextMethods;
|
| 1123 |
+
},
|
| 1124 |
+
exposeAction(name2, actionCreator) {
|
| 1125 |
+
context.actionCreators[name2] = actionCreator;
|
| 1126 |
+
return contextMethods;
|
| 1127 |
+
},
|
| 1128 |
+
exposeCaseReducer(name2, reducer2) {
|
| 1129 |
+
context.sliceCaseReducersByName[name2] = reducer2;
|
| 1130 |
+
return contextMethods;
|
| 1131 |
+
}
|
| 1132 |
+
};
|
| 1133 |
+
reducerNames.forEach((reducerName) => {
|
| 1134 |
+
const reducerDefinition = reducers[reducerName];
|
| 1135 |
+
const reducerDetails = {
|
| 1136 |
+
reducerName,
|
| 1137 |
+
type: getType(name, reducerName),
|
| 1138 |
+
createNotation: typeof options.reducers === "function"
|
| 1139 |
+
};
|
| 1140 |
+
if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) {
|
| 1141 |
+
handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
|
| 1142 |
+
} else {
|
| 1143 |
+
handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
| 1144 |
+
}
|
| 1145 |
+
});
|
| 1146 |
+
function buildReducer() {
|
| 1147 |
+
if (true) {
|
| 1148 |
+
if (typeof options.extraReducers === "object") {
|
| 1149 |
+
throw new Error(false ? _formatProdErrorMessage4(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
|
| 1150 |
+
}
|
| 1151 |
+
}
|
| 1152 |
+
const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
|
| 1153 |
+
const finalCaseReducers = {
|
| 1154 |
+
...extraReducers,
|
| 1155 |
+
...context.sliceCaseReducersByType
|
| 1156 |
+
};
|
| 1157 |
+
return createReducer(options.initialState, (builder) => {
|
| 1158 |
+
for (let key in finalCaseReducers) {
|
| 1159 |
+
builder.addCase(key, finalCaseReducers[key]);
|
| 1160 |
+
}
|
| 1161 |
+
for (let sM of context.sliceMatchers) {
|
| 1162 |
+
builder.addMatcher(sM.matcher, sM.reducer);
|
| 1163 |
+
}
|
| 1164 |
+
for (let m of actionMatchers) {
|
| 1165 |
+
builder.addMatcher(m.matcher, m.reducer);
|
| 1166 |
+
}
|
| 1167 |
+
if (defaultCaseReducer) {
|
| 1168 |
+
builder.addDefaultCase(defaultCaseReducer);
|
| 1169 |
+
}
|
| 1170 |
+
});
|
| 1171 |
+
}
|
| 1172 |
+
const selectSelf = (state) => state;
|
| 1173 |
+
const injectedSelectorCache = /* @__PURE__ */ new Map();
|
| 1174 |
+
const injectedStateCache = /* @__PURE__ */ new WeakMap();
|
| 1175 |
+
let _reducer;
|
| 1176 |
+
function reducer(state, action) {
|
| 1177 |
+
if (!_reducer) _reducer = buildReducer();
|
| 1178 |
+
return _reducer(state, action);
|
| 1179 |
+
}
|
| 1180 |
+
function getInitialState() {
|
| 1181 |
+
if (!_reducer) _reducer = buildReducer();
|
| 1182 |
+
return _reducer.getInitialState();
|
| 1183 |
+
}
|
| 1184 |
+
function makeSelectorProps(reducerPath2, injected = false) {
|
| 1185 |
+
function selectSlice(state) {
|
| 1186 |
+
let sliceState = state[reducerPath2];
|
| 1187 |
+
if (typeof sliceState === "undefined") {
|
| 1188 |
+
if (injected) {
|
| 1189 |
+
sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
|
| 1190 |
+
} else if (true) {
|
| 1191 |
+
throw new Error(false ? _formatProdErrorMessage5(15) : "selectSlice returned undefined for an uninjected slice reducer");
|
| 1192 |
+
}
|
| 1193 |
+
}
|
| 1194 |
+
return sliceState;
|
| 1195 |
+
}
|
| 1196 |
+
function getSelectors(selectState = selectSelf) {
|
| 1197 |
+
const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
|
| 1198 |
+
return getOrInsertComputed(selectorCache, selectState, () => {
|
| 1199 |
+
const map = {};
|
| 1200 |
+
for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
|
| 1201 |
+
map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
|
| 1202 |
+
}
|
| 1203 |
+
return map;
|
| 1204 |
+
});
|
| 1205 |
+
}
|
| 1206 |
+
return {
|
| 1207 |
+
reducerPath: reducerPath2,
|
| 1208 |
+
getSelectors,
|
| 1209 |
+
get selectors() {
|
| 1210 |
+
return getSelectors(selectSlice);
|
| 1211 |
+
},
|
| 1212 |
+
selectSlice
|
| 1213 |
+
};
|
| 1214 |
+
}
|
| 1215 |
+
const slice = {
|
| 1216 |
+
name,
|
| 1217 |
+
reducer,
|
| 1218 |
+
actions: context.actionCreators,
|
| 1219 |
+
caseReducers: context.sliceCaseReducersByName,
|
| 1220 |
+
getInitialState,
|
| 1221 |
+
...makeSelectorProps(reducerPath),
|
| 1222 |
+
injectInto(injectable, {
|
| 1223 |
+
reducerPath: pathOpt,
|
| 1224 |
+
...config
|
| 1225 |
+
} = {}) {
|
| 1226 |
+
const newReducerPath = pathOpt ?? reducerPath;
|
| 1227 |
+
injectable.inject({
|
| 1228 |
+
reducerPath: newReducerPath,
|
| 1229 |
+
reducer
|
| 1230 |
+
}, config);
|
| 1231 |
+
return {
|
| 1232 |
+
...slice,
|
| 1233 |
+
...makeSelectorProps(newReducerPath, true)
|
| 1234 |
+
};
|
| 1235 |
+
}
|
| 1236 |
+
};
|
| 1237 |
+
return slice;
|
| 1238 |
+
};
|
| 1239 |
+
}
|
| 1240 |
+
function wrapSelector(selector, selectState, getInitialState, injected) {
|
| 1241 |
+
function wrapper(rootState, ...args) {
|
| 1242 |
+
let sliceState = selectState(rootState);
|
| 1243 |
+
if (typeof sliceState === "undefined") {
|
| 1244 |
+
if (injected) {
|
| 1245 |
+
sliceState = getInitialState();
|
| 1246 |
+
} else if (true) {
|
| 1247 |
+
throw new Error(false ? _formatProdErrorMessage6(16) : "selectState returned undefined for an uninjected slice reducer");
|
| 1248 |
+
}
|
| 1249 |
+
}
|
| 1250 |
+
return selector(sliceState, ...args);
|
| 1251 |
+
}
|
| 1252 |
+
wrapper.unwrapped = selector;
|
| 1253 |
+
return wrapper;
|
| 1254 |
+
}
|
| 1255 |
+
var createSlice = /* @__PURE__ */ buildCreateSlice();
|
| 1256 |
+
function buildReducerCreators() {
|
| 1257 |
+
function asyncThunk(payloadCreator, config) {
|
| 1258 |
+
return {
|
| 1259 |
+
_reducerDefinitionType: "asyncThunk" /* asyncThunk */,
|
| 1260 |
+
payloadCreator,
|
| 1261 |
+
...config
|
| 1262 |
+
};
|
| 1263 |
+
}
|
| 1264 |
+
asyncThunk.withTypes = () => asyncThunk;
|
| 1265 |
+
return {
|
| 1266 |
+
reducer(caseReducer) {
|
| 1267 |
+
return Object.assign({
|
| 1268 |
+
// hack so the wrapping function has the same name as the original
|
| 1269 |
+
// we need to create a wrapper so the `reducerDefinitionType` is not assigned to the original
|
| 1270 |
+
[caseReducer.name](...args) {
|
| 1271 |
+
return caseReducer(...args);
|
| 1272 |
+
}
|
| 1273 |
+
}[caseReducer.name], {
|
| 1274 |
+
_reducerDefinitionType: "reducer" /* reducer */
|
| 1275 |
+
});
|
| 1276 |
+
},
|
| 1277 |
+
preparedReducer(prepare, reducer) {
|
| 1278 |
+
return {
|
| 1279 |
+
_reducerDefinitionType: "reducerWithPrepare" /* reducerWithPrepare */,
|
| 1280 |
+
prepare,
|
| 1281 |
+
reducer
|
| 1282 |
+
};
|
| 1283 |
+
},
|
| 1284 |
+
asyncThunk
|
| 1285 |
+
};
|
| 1286 |
+
}
|
| 1287 |
+
function handleNormalReducerDefinition({
|
| 1288 |
+
type,
|
| 1289 |
+
reducerName,
|
| 1290 |
+
createNotation
|
| 1291 |
+
}, maybeReducerWithPrepare, context) {
|
| 1292 |
+
let caseReducer;
|
| 1293 |
+
let prepareCallback;
|
| 1294 |
+
if ("reducer" in maybeReducerWithPrepare) {
|
| 1295 |
+
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) {
|
| 1296 |
+
throw new Error(false ? _formatProdErrorMessage7(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
| 1297 |
+
}
|
| 1298 |
+
caseReducer = maybeReducerWithPrepare.reducer;
|
| 1299 |
+
prepareCallback = maybeReducerWithPrepare.prepare;
|
| 1300 |
+
} else {
|
| 1301 |
+
caseReducer = maybeReducerWithPrepare;
|
| 1302 |
+
}
|
| 1303 |
+
context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
|
| 1304 |
+
}
|
| 1305 |
+
function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
|
| 1306 |
+
return reducerDefinition._reducerDefinitionType === "asyncThunk" /* asyncThunk */;
|
| 1307 |
+
}
|
| 1308 |
+
function isCaseReducerWithPrepareDefinition(reducerDefinition) {
|
| 1309 |
+
return reducerDefinition._reducerDefinitionType === "reducerWithPrepare" /* reducerWithPrepare */;
|
| 1310 |
+
}
|
| 1311 |
+
function handleThunkCaseReducerDefinition({
|
| 1312 |
+
type,
|
| 1313 |
+
reducerName
|
| 1314 |
+
}, reducerDefinition, context, cAT) {
|
| 1315 |
+
if (!cAT) {
|
| 1316 |
+
throw new Error(false ? _formatProdErrorMessage8(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
|
| 1317 |
+
}
|
| 1318 |
+
const {
|
| 1319 |
+
payloadCreator,
|
| 1320 |
+
fulfilled,
|
| 1321 |
+
pending,
|
| 1322 |
+
rejected,
|
| 1323 |
+
settled,
|
| 1324 |
+
options
|
| 1325 |
+
} = reducerDefinition;
|
| 1326 |
+
const thunk = cAT(type, payloadCreator, options);
|
| 1327 |
+
context.exposeAction(reducerName, thunk);
|
| 1328 |
+
if (fulfilled) {
|
| 1329 |
+
context.addCase(thunk.fulfilled, fulfilled);
|
| 1330 |
+
}
|
| 1331 |
+
if (pending) {
|
| 1332 |
+
context.addCase(thunk.pending, pending);
|
| 1333 |
+
}
|
| 1334 |
+
if (rejected) {
|
| 1335 |
+
context.addCase(thunk.rejected, rejected);
|
| 1336 |
+
}
|
| 1337 |
+
if (settled) {
|
| 1338 |
+
context.addMatcher(thunk.settled, settled);
|
| 1339 |
+
}
|
| 1340 |
+
context.exposeCaseReducer(reducerName, {
|
| 1341 |
+
fulfilled: fulfilled || noop,
|
| 1342 |
+
pending: pending || noop,
|
| 1343 |
+
rejected: rejected || noop,
|
| 1344 |
+
settled: settled || noop
|
| 1345 |
+
});
|
| 1346 |
+
}
|
| 1347 |
+
function noop() {
|
| 1348 |
+
}
|
| 1349 |
+
|
| 1350 |
+
// src/entities/entity_state.ts
|
| 1351 |
+
function getInitialEntityState() {
|
| 1352 |
+
return {
|
| 1353 |
+
ids: [],
|
| 1354 |
+
entities: {}
|
| 1355 |
+
};
|
| 1356 |
+
}
|
| 1357 |
+
function createInitialStateFactory(stateAdapter) {
|
| 1358 |
+
function getInitialState(additionalState = {}, entities) {
|
| 1359 |
+
const state = Object.assign(getInitialEntityState(), additionalState);
|
| 1360 |
+
return entities ? stateAdapter.setAll(state, entities) : state;
|
| 1361 |
+
}
|
| 1362 |
+
return {
|
| 1363 |
+
getInitialState
|
| 1364 |
+
};
|
| 1365 |
+
}
|
| 1366 |
+
|
| 1367 |
+
// src/entities/state_selectors.ts
|
| 1368 |
+
function createSelectorsFactory() {
|
| 1369 |
+
function getSelectors(selectState, options = {}) {
|
| 1370 |
+
const {
|
| 1371 |
+
createSelector: createSelector2 = createDraftSafeSelector
|
| 1372 |
+
} = options;
|
| 1373 |
+
const selectIds = (state) => state.ids;
|
| 1374 |
+
const selectEntities = (state) => state.entities;
|
| 1375 |
+
const selectAll = createSelector2(selectIds, selectEntities, (ids, entities) => ids.map((id) => entities[id]));
|
| 1376 |
+
const selectId = (_, id) => id;
|
| 1377 |
+
const selectById = (entities, id) => entities[id];
|
| 1378 |
+
const selectTotal = createSelector2(selectIds, (ids) => ids.length);
|
| 1379 |
+
if (!selectState) {
|
| 1380 |
+
return {
|
| 1381 |
+
selectIds,
|
| 1382 |
+
selectEntities,
|
| 1383 |
+
selectAll,
|
| 1384 |
+
selectTotal,
|
| 1385 |
+
selectById: createSelector2(selectEntities, selectId, selectById)
|
| 1386 |
+
};
|
| 1387 |
+
}
|
| 1388 |
+
const selectGlobalizedEntities = createSelector2(selectState, selectEntities);
|
| 1389 |
+
return {
|
| 1390 |
+
selectIds: createSelector2(selectState, selectIds),
|
| 1391 |
+
selectEntities: selectGlobalizedEntities,
|
| 1392 |
+
selectAll: createSelector2(selectState, selectAll),
|
| 1393 |
+
selectTotal: createSelector2(selectState, selectTotal),
|
| 1394 |
+
selectById: createSelector2(selectGlobalizedEntities, selectId, selectById)
|
| 1395 |
+
};
|
| 1396 |
+
}
|
| 1397 |
+
return {
|
| 1398 |
+
getSelectors
|
| 1399 |
+
};
|
| 1400 |
+
}
|
| 1401 |
+
|
| 1402 |
+
// src/entities/state_adapter.ts
|
| 1403 |
+
var import_immer4 = require("immer");
|
| 1404 |
+
var isDraftTyped = import_immer4.isDraft;
|
| 1405 |
+
function createSingleArgumentStateOperator(mutator) {
|
| 1406 |
+
const operator = createStateOperator((_, state) => mutator(state));
|
| 1407 |
+
return function operation(state) {
|
| 1408 |
+
return operator(state, void 0);
|
| 1409 |
+
};
|
| 1410 |
+
}
|
| 1411 |
+
function createStateOperator(mutator) {
|
| 1412 |
+
return function operation(state, arg) {
|
| 1413 |
+
function isPayloadActionArgument(arg2) {
|
| 1414 |
+
return isFSA(arg2);
|
| 1415 |
+
}
|
| 1416 |
+
const runMutator = (draft) => {
|
| 1417 |
+
if (isPayloadActionArgument(arg)) {
|
| 1418 |
+
mutator(arg.payload, draft);
|
| 1419 |
+
} else {
|
| 1420 |
+
mutator(arg, draft);
|
| 1421 |
+
}
|
| 1422 |
+
};
|
| 1423 |
+
if (isDraftTyped(state)) {
|
| 1424 |
+
runMutator(state);
|
| 1425 |
+
return state;
|
| 1426 |
+
}
|
| 1427 |
+
return (0, import_immer4.produce)(state, runMutator);
|
| 1428 |
+
};
|
| 1429 |
+
}
|
| 1430 |
+
|
| 1431 |
+
// src/entities/utils.ts
|
| 1432 |
+
var import_immer5 = require("immer");
|
| 1433 |
+
function selectIdValue(entity, selectId) {
|
| 1434 |
+
const key = selectId(entity);
|
| 1435 |
+
if (key === void 0) {
|
| 1436 |
+
console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
|
| 1437 |
+
}
|
| 1438 |
+
return key;
|
| 1439 |
+
}
|
| 1440 |
+
function ensureEntitiesArray(entities) {
|
| 1441 |
+
if (!Array.isArray(entities)) {
|
| 1442 |
+
entities = Object.values(entities);
|
| 1443 |
+
}
|
| 1444 |
+
return entities;
|
| 1445 |
+
}
|
| 1446 |
+
function getCurrent(value) {
|
| 1447 |
+
return (0, import_immer5.isDraft)(value) ? (0, import_immer5.current)(value) : value;
|
| 1448 |
+
}
|
| 1449 |
+
function splitAddedUpdatedEntities(newEntities, selectId, state) {
|
| 1450 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1451 |
+
const existingIdsArray = getCurrent(state.ids);
|
| 1452 |
+
const existingIds = new Set(existingIdsArray);
|
| 1453 |
+
const added = [];
|
| 1454 |
+
const addedIds = /* @__PURE__ */ new Set([]);
|
| 1455 |
+
const updated = [];
|
| 1456 |
+
for (const entity of newEntities) {
|
| 1457 |
+
const id = selectIdValue(entity, selectId);
|
| 1458 |
+
if (existingIds.has(id) || addedIds.has(id)) {
|
| 1459 |
+
updated.push({
|
| 1460 |
+
id,
|
| 1461 |
+
changes: entity
|
| 1462 |
+
});
|
| 1463 |
+
} else {
|
| 1464 |
+
addedIds.add(id);
|
| 1465 |
+
added.push(entity);
|
| 1466 |
+
}
|
| 1467 |
+
}
|
| 1468 |
+
return [added, updated, existingIdsArray];
|
| 1469 |
+
}
|
| 1470 |
+
|
| 1471 |
+
// src/entities/unsorted_state_adapter.ts
|
| 1472 |
+
function createUnsortedStateAdapter(selectId) {
|
| 1473 |
+
function addOneMutably(entity, state) {
|
| 1474 |
+
const key = selectIdValue(entity, selectId);
|
| 1475 |
+
if (key in state.entities) {
|
| 1476 |
+
return;
|
| 1477 |
+
}
|
| 1478 |
+
state.ids.push(key);
|
| 1479 |
+
state.entities[key] = entity;
|
| 1480 |
+
}
|
| 1481 |
+
function addManyMutably(newEntities, state) {
|
| 1482 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1483 |
+
for (const entity of newEntities) {
|
| 1484 |
+
addOneMutably(entity, state);
|
| 1485 |
+
}
|
| 1486 |
+
}
|
| 1487 |
+
function setOneMutably(entity, state) {
|
| 1488 |
+
const key = selectIdValue(entity, selectId);
|
| 1489 |
+
if (!(key in state.entities)) {
|
| 1490 |
+
state.ids.push(key);
|
| 1491 |
+
}
|
| 1492 |
+
;
|
| 1493 |
+
state.entities[key] = entity;
|
| 1494 |
+
}
|
| 1495 |
+
function setManyMutably(newEntities, state) {
|
| 1496 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1497 |
+
for (const entity of newEntities) {
|
| 1498 |
+
setOneMutably(entity, state);
|
| 1499 |
+
}
|
| 1500 |
+
}
|
| 1501 |
+
function setAllMutably(newEntities, state) {
|
| 1502 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1503 |
+
state.ids = [];
|
| 1504 |
+
state.entities = {};
|
| 1505 |
+
addManyMutably(newEntities, state);
|
| 1506 |
+
}
|
| 1507 |
+
function removeOneMutably(key, state) {
|
| 1508 |
+
return removeManyMutably([key], state);
|
| 1509 |
+
}
|
| 1510 |
+
function removeManyMutably(keys, state) {
|
| 1511 |
+
let didMutate = false;
|
| 1512 |
+
keys.forEach((key) => {
|
| 1513 |
+
if (key in state.entities) {
|
| 1514 |
+
delete state.entities[key];
|
| 1515 |
+
didMutate = true;
|
| 1516 |
+
}
|
| 1517 |
+
});
|
| 1518 |
+
if (didMutate) {
|
| 1519 |
+
state.ids = state.ids.filter((id) => id in state.entities);
|
| 1520 |
+
}
|
| 1521 |
+
}
|
| 1522 |
+
function removeAllMutably(state) {
|
| 1523 |
+
Object.assign(state, {
|
| 1524 |
+
ids: [],
|
| 1525 |
+
entities: {}
|
| 1526 |
+
});
|
| 1527 |
+
}
|
| 1528 |
+
function takeNewKey(keys, update, state) {
|
| 1529 |
+
const original3 = state.entities[update.id];
|
| 1530 |
+
if (original3 === void 0) {
|
| 1531 |
+
return false;
|
| 1532 |
+
}
|
| 1533 |
+
const updated = Object.assign({}, original3, update.changes);
|
| 1534 |
+
const newKey = selectIdValue(updated, selectId);
|
| 1535 |
+
const hasNewKey = newKey !== update.id;
|
| 1536 |
+
if (hasNewKey) {
|
| 1537 |
+
keys[update.id] = newKey;
|
| 1538 |
+
delete state.entities[update.id];
|
| 1539 |
+
}
|
| 1540 |
+
;
|
| 1541 |
+
state.entities[newKey] = updated;
|
| 1542 |
+
return hasNewKey;
|
| 1543 |
+
}
|
| 1544 |
+
function updateOneMutably(update, state) {
|
| 1545 |
+
return updateManyMutably([update], state);
|
| 1546 |
+
}
|
| 1547 |
+
function updateManyMutably(updates, state) {
|
| 1548 |
+
const newKeys = {};
|
| 1549 |
+
const updatesPerEntity = {};
|
| 1550 |
+
updates.forEach((update) => {
|
| 1551 |
+
if (update.id in state.entities) {
|
| 1552 |
+
updatesPerEntity[update.id] = {
|
| 1553 |
+
id: update.id,
|
| 1554 |
+
// Spreads ignore falsy values, so this works even if there isn't
|
| 1555 |
+
// an existing update already at this key
|
| 1556 |
+
changes: {
|
| 1557 |
+
...updatesPerEntity[update.id]?.changes,
|
| 1558 |
+
...update.changes
|
| 1559 |
+
}
|
| 1560 |
+
};
|
| 1561 |
+
}
|
| 1562 |
+
});
|
| 1563 |
+
updates = Object.values(updatesPerEntity);
|
| 1564 |
+
const didMutateEntities = updates.length > 0;
|
| 1565 |
+
if (didMutateEntities) {
|
| 1566 |
+
const didMutateIds = updates.filter((update) => takeNewKey(newKeys, update, state)).length > 0;
|
| 1567 |
+
if (didMutateIds) {
|
| 1568 |
+
state.ids = Object.values(state.entities).map((e) => selectIdValue(e, selectId));
|
| 1569 |
+
}
|
| 1570 |
+
}
|
| 1571 |
+
}
|
| 1572 |
+
function upsertOneMutably(entity, state) {
|
| 1573 |
+
return upsertManyMutably([entity], state);
|
| 1574 |
+
}
|
| 1575 |
+
function upsertManyMutably(newEntities, state) {
|
| 1576 |
+
const [added, updated] = splitAddedUpdatedEntities(newEntities, selectId, state);
|
| 1577 |
+
addManyMutably(added, state);
|
| 1578 |
+
updateManyMutably(updated, state);
|
| 1579 |
+
}
|
| 1580 |
+
return {
|
| 1581 |
+
removeAll: createSingleArgumentStateOperator(removeAllMutably),
|
| 1582 |
+
addOne: createStateOperator(addOneMutably),
|
| 1583 |
+
addMany: createStateOperator(addManyMutably),
|
| 1584 |
+
setOne: createStateOperator(setOneMutably),
|
| 1585 |
+
setMany: createStateOperator(setManyMutably),
|
| 1586 |
+
setAll: createStateOperator(setAllMutably),
|
| 1587 |
+
updateOne: createStateOperator(updateOneMutably),
|
| 1588 |
+
updateMany: createStateOperator(updateManyMutably),
|
| 1589 |
+
upsertOne: createStateOperator(upsertOneMutably),
|
| 1590 |
+
upsertMany: createStateOperator(upsertManyMutably),
|
| 1591 |
+
removeOne: createStateOperator(removeOneMutably),
|
| 1592 |
+
removeMany: createStateOperator(removeManyMutably)
|
| 1593 |
+
};
|
| 1594 |
+
}
|
| 1595 |
+
|
| 1596 |
+
// src/entities/sorted_state_adapter.ts
|
| 1597 |
+
function findInsertIndex(sortedItems, item, comparisonFunction) {
|
| 1598 |
+
let lowIndex = 0;
|
| 1599 |
+
let highIndex = sortedItems.length;
|
| 1600 |
+
while (lowIndex < highIndex) {
|
| 1601 |
+
let middleIndex = lowIndex + highIndex >>> 1;
|
| 1602 |
+
const currentItem = sortedItems[middleIndex];
|
| 1603 |
+
const res = comparisonFunction(item, currentItem);
|
| 1604 |
+
if (res >= 0) {
|
| 1605 |
+
lowIndex = middleIndex + 1;
|
| 1606 |
+
} else {
|
| 1607 |
+
highIndex = middleIndex;
|
| 1608 |
+
}
|
| 1609 |
+
}
|
| 1610 |
+
return lowIndex;
|
| 1611 |
+
}
|
| 1612 |
+
function insert(sortedItems, item, comparisonFunction) {
|
| 1613 |
+
const insertAtIndex = findInsertIndex(sortedItems, item, comparisonFunction);
|
| 1614 |
+
sortedItems.splice(insertAtIndex, 0, item);
|
| 1615 |
+
return sortedItems;
|
| 1616 |
+
}
|
| 1617 |
+
function createSortedStateAdapter(selectId, comparer) {
|
| 1618 |
+
const {
|
| 1619 |
+
removeOne,
|
| 1620 |
+
removeMany,
|
| 1621 |
+
removeAll
|
| 1622 |
+
} = createUnsortedStateAdapter(selectId);
|
| 1623 |
+
function addOneMutably(entity, state) {
|
| 1624 |
+
return addManyMutably([entity], state);
|
| 1625 |
+
}
|
| 1626 |
+
function addManyMutably(newEntities, state, existingIds) {
|
| 1627 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1628 |
+
const existingKeys = new Set(existingIds ?? getCurrent(state.ids));
|
| 1629 |
+
const models = newEntities.filter((model) => !existingKeys.has(selectIdValue(model, selectId)));
|
| 1630 |
+
if (models.length !== 0) {
|
| 1631 |
+
mergeFunction(state, models);
|
| 1632 |
+
}
|
| 1633 |
+
}
|
| 1634 |
+
function setOneMutably(entity, state) {
|
| 1635 |
+
return setManyMutably([entity], state);
|
| 1636 |
+
}
|
| 1637 |
+
function setManyMutably(newEntities, state) {
|
| 1638 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1639 |
+
if (newEntities.length !== 0) {
|
| 1640 |
+
for (const item of newEntities) {
|
| 1641 |
+
delete state.entities[selectId(item)];
|
| 1642 |
+
}
|
| 1643 |
+
mergeFunction(state, newEntities);
|
| 1644 |
+
}
|
| 1645 |
+
}
|
| 1646 |
+
function setAllMutably(newEntities, state) {
|
| 1647 |
+
newEntities = ensureEntitiesArray(newEntities);
|
| 1648 |
+
state.entities = {};
|
| 1649 |
+
state.ids = [];
|
| 1650 |
+
addManyMutably(newEntities, state, []);
|
| 1651 |
+
}
|
| 1652 |
+
function updateOneMutably(update, state) {
|
| 1653 |
+
return updateManyMutably([update], state);
|
| 1654 |
+
}
|
| 1655 |
+
function updateManyMutably(updates, state) {
|
| 1656 |
+
let appliedUpdates = false;
|
| 1657 |
+
let replacedIds = false;
|
| 1658 |
+
for (let update of updates) {
|
| 1659 |
+
const entity = state.entities[update.id];
|
| 1660 |
+
if (!entity) {
|
| 1661 |
+
continue;
|
| 1662 |
+
}
|
| 1663 |
+
appliedUpdates = true;
|
| 1664 |
+
Object.assign(entity, update.changes);
|
| 1665 |
+
const newId = selectId(entity);
|
| 1666 |
+
if (update.id !== newId) {
|
| 1667 |
+
replacedIds = true;
|
| 1668 |
+
delete state.entities[update.id];
|
| 1669 |
+
const oldIndex = state.ids.indexOf(update.id);
|
| 1670 |
+
state.ids[oldIndex] = newId;
|
| 1671 |
+
state.entities[newId] = entity;
|
| 1672 |
+
}
|
| 1673 |
+
}
|
| 1674 |
+
if (appliedUpdates) {
|
| 1675 |
+
mergeFunction(state, [], appliedUpdates, replacedIds);
|
| 1676 |
+
}
|
| 1677 |
+
}
|
| 1678 |
+
function upsertOneMutably(entity, state) {
|
| 1679 |
+
return upsertManyMutably([entity], state);
|
| 1680 |
+
}
|
| 1681 |
+
function upsertManyMutably(newEntities, state) {
|
| 1682 |
+
const [added, updated, existingIdsArray] = splitAddedUpdatedEntities(newEntities, selectId, state);
|
| 1683 |
+
if (added.length) {
|
| 1684 |
+
addManyMutably(added, state, existingIdsArray);
|
| 1685 |
+
}
|
| 1686 |
+
if (updated.length) {
|
| 1687 |
+
updateManyMutably(updated, state);
|
| 1688 |
+
}
|
| 1689 |
+
}
|
| 1690 |
+
function areArraysEqual(a, b) {
|
| 1691 |
+
if (a.length !== b.length) {
|
| 1692 |
+
return false;
|
| 1693 |
+
}
|
| 1694 |
+
for (let i = 0; i < a.length; i++) {
|
| 1695 |
+
if (a[i] === b[i]) {
|
| 1696 |
+
continue;
|
| 1697 |
+
}
|
| 1698 |
+
return false;
|
| 1699 |
+
}
|
| 1700 |
+
return true;
|
| 1701 |
+
}
|
| 1702 |
+
const mergeFunction = (state, addedItems, appliedUpdates, replacedIds) => {
|
| 1703 |
+
const currentEntities = getCurrent(state.entities);
|
| 1704 |
+
const currentIds = getCurrent(state.ids);
|
| 1705 |
+
const stateEntities = state.entities;
|
| 1706 |
+
let ids = currentIds;
|
| 1707 |
+
if (replacedIds) {
|
| 1708 |
+
ids = new Set(currentIds);
|
| 1709 |
+
}
|
| 1710 |
+
let sortedEntities = [];
|
| 1711 |
+
for (const id of ids) {
|
| 1712 |
+
const entity = currentEntities[id];
|
| 1713 |
+
if (entity) {
|
| 1714 |
+
sortedEntities.push(entity);
|
| 1715 |
+
}
|
| 1716 |
+
}
|
| 1717 |
+
const wasPreviouslyEmpty = sortedEntities.length === 0;
|
| 1718 |
+
for (const item of addedItems) {
|
| 1719 |
+
stateEntities[selectId(item)] = item;
|
| 1720 |
+
if (!wasPreviouslyEmpty) {
|
| 1721 |
+
insert(sortedEntities, item, comparer);
|
| 1722 |
+
}
|
| 1723 |
+
}
|
| 1724 |
+
if (wasPreviouslyEmpty) {
|
| 1725 |
+
sortedEntities = addedItems.slice().sort(comparer);
|
| 1726 |
+
} else if (appliedUpdates) {
|
| 1727 |
+
sortedEntities.sort(comparer);
|
| 1728 |
+
}
|
| 1729 |
+
const newSortedIds = sortedEntities.map(selectId);
|
| 1730 |
+
if (!areArraysEqual(currentIds, newSortedIds)) {
|
| 1731 |
+
state.ids = newSortedIds;
|
| 1732 |
+
}
|
| 1733 |
+
};
|
| 1734 |
+
return {
|
| 1735 |
+
removeOne,
|
| 1736 |
+
removeMany,
|
| 1737 |
+
removeAll,
|
| 1738 |
+
addOne: createStateOperator(addOneMutably),
|
| 1739 |
+
updateOne: createStateOperator(updateOneMutably),
|
| 1740 |
+
upsertOne: createStateOperator(upsertOneMutably),
|
| 1741 |
+
setOne: createStateOperator(setOneMutably),
|
| 1742 |
+
setMany: createStateOperator(setManyMutably),
|
| 1743 |
+
setAll: createStateOperator(setAllMutably),
|
| 1744 |
+
addMany: createStateOperator(addManyMutably),
|
| 1745 |
+
updateMany: createStateOperator(updateManyMutably),
|
| 1746 |
+
upsertMany: createStateOperator(upsertManyMutably)
|
| 1747 |
+
};
|
| 1748 |
+
}
|
| 1749 |
+
|
| 1750 |
+
// src/entities/create_adapter.ts
|
| 1751 |
+
function createEntityAdapter(options = {}) {
|
| 1752 |
+
const {
|
| 1753 |
+
selectId,
|
| 1754 |
+
sortComparer
|
| 1755 |
+
} = {
|
| 1756 |
+
sortComparer: false,
|
| 1757 |
+
selectId: (instance) => instance.id,
|
| 1758 |
+
...options
|
| 1759 |
+
};
|
| 1760 |
+
const stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
|
| 1761 |
+
const stateFactory = createInitialStateFactory(stateAdapter);
|
| 1762 |
+
const selectorsFactory = createSelectorsFactory();
|
| 1763 |
+
return {
|
| 1764 |
+
selectId,
|
| 1765 |
+
sortComparer,
|
| 1766 |
+
...stateFactory,
|
| 1767 |
+
...selectorsFactory,
|
| 1768 |
+
...stateAdapter
|
| 1769 |
+
};
|
| 1770 |
+
}
|
| 1771 |
+
|
| 1772 |
+
// src/listenerMiddleware/index.ts
|
| 1773 |
+
var import_redux5 = require("redux");
|
| 1774 |
+
|
| 1775 |
+
// src/listenerMiddleware/exceptions.ts
|
| 1776 |
+
var task = "task";
|
| 1777 |
+
var listener = "listener";
|
| 1778 |
+
var completed = "completed";
|
| 1779 |
+
var cancelled = "cancelled";
|
| 1780 |
+
var taskCancelled = `task-${cancelled}`;
|
| 1781 |
+
var taskCompleted = `task-${completed}`;
|
| 1782 |
+
var listenerCancelled = `${listener}-${cancelled}`;
|
| 1783 |
+
var listenerCompleted = `${listener}-${completed}`;
|
| 1784 |
+
var TaskAbortError = class {
|
| 1785 |
+
constructor(code) {
|
| 1786 |
+
this.code = code;
|
| 1787 |
+
this.message = `${task} ${cancelled} (reason: ${code})`;
|
| 1788 |
+
}
|
| 1789 |
+
name = "TaskAbortError";
|
| 1790 |
+
message;
|
| 1791 |
+
};
|
| 1792 |
+
|
| 1793 |
+
// src/listenerMiddleware/utils.ts
|
| 1794 |
+
var assertFunction = (func, expected) => {
|
| 1795 |
+
if (typeof func !== "function") {
|
| 1796 |
+
throw new TypeError(false ? _formatProdErrorMessage(32) : `${expected} is not a function`);
|
| 1797 |
+
}
|
| 1798 |
+
};
|
| 1799 |
+
var noop2 = () => {
|
| 1800 |
+
};
|
| 1801 |
+
var catchRejection = (promise, onError = noop2) => {
|
| 1802 |
+
promise.catch(onError);
|
| 1803 |
+
return promise;
|
| 1804 |
+
};
|
| 1805 |
+
var addAbortSignalListener = (abortSignal, callback) => {
|
| 1806 |
+
abortSignal.addEventListener("abort", callback, {
|
| 1807 |
+
once: true
|
| 1808 |
+
});
|
| 1809 |
+
return () => abortSignal.removeEventListener("abort", callback);
|
| 1810 |
+
};
|
| 1811 |
+
var abortControllerWithReason = (abortController, reason) => {
|
| 1812 |
+
const signal = abortController.signal;
|
| 1813 |
+
if (signal.aborted) {
|
| 1814 |
+
return;
|
| 1815 |
+
}
|
| 1816 |
+
if (!("reason" in signal)) {
|
| 1817 |
+
Object.defineProperty(signal, "reason", {
|
| 1818 |
+
enumerable: true,
|
| 1819 |
+
value: reason,
|
| 1820 |
+
configurable: true,
|
| 1821 |
+
writable: true
|
| 1822 |
+
});
|
| 1823 |
+
}
|
| 1824 |
+
;
|
| 1825 |
+
abortController.abort(reason);
|
| 1826 |
+
};
|
| 1827 |
+
|
| 1828 |
+
// src/listenerMiddleware/task.ts
|
| 1829 |
+
var validateActive = (signal) => {
|
| 1830 |
+
if (signal.aborted) {
|
| 1831 |
+
const {
|
| 1832 |
+
reason
|
| 1833 |
+
} = signal;
|
| 1834 |
+
throw new TaskAbortError(reason);
|
| 1835 |
+
}
|
| 1836 |
+
};
|
| 1837 |
+
function raceWithSignal(signal, promise) {
|
| 1838 |
+
let cleanup = noop2;
|
| 1839 |
+
return new Promise((resolve, reject) => {
|
| 1840 |
+
const notifyRejection = () => reject(new TaskAbortError(signal.reason));
|
| 1841 |
+
if (signal.aborted) {
|
| 1842 |
+
notifyRejection();
|
| 1843 |
+
return;
|
| 1844 |
+
}
|
| 1845 |
+
cleanup = addAbortSignalListener(signal, notifyRejection);
|
| 1846 |
+
promise.finally(() => cleanup()).then(resolve, reject);
|
| 1847 |
+
}).finally(() => {
|
| 1848 |
+
cleanup = noop2;
|
| 1849 |
+
});
|
| 1850 |
+
}
|
| 1851 |
+
var runTask = async (task2, cleanUp) => {
|
| 1852 |
+
try {
|
| 1853 |
+
await Promise.resolve();
|
| 1854 |
+
const value = await task2();
|
| 1855 |
+
return {
|
| 1856 |
+
status: "ok",
|
| 1857 |
+
value
|
| 1858 |
+
};
|
| 1859 |
+
} catch (error) {
|
| 1860 |
+
return {
|
| 1861 |
+
status: error instanceof TaskAbortError ? "cancelled" : "rejected",
|
| 1862 |
+
error
|
| 1863 |
+
};
|
| 1864 |
+
} finally {
|
| 1865 |
+
cleanUp?.();
|
| 1866 |
+
}
|
| 1867 |
+
};
|
| 1868 |
+
var createPause = (signal) => {
|
| 1869 |
+
return (promise) => {
|
| 1870 |
+
return catchRejection(raceWithSignal(signal, promise).then((output) => {
|
| 1871 |
+
validateActive(signal);
|
| 1872 |
+
return output;
|
| 1873 |
+
}));
|
| 1874 |
+
};
|
| 1875 |
+
};
|
| 1876 |
+
var createDelay = (signal) => {
|
| 1877 |
+
const pause = createPause(signal);
|
| 1878 |
+
return (timeoutMs) => {
|
| 1879 |
+
return pause(new Promise((resolve) => setTimeout(resolve, timeoutMs)));
|
| 1880 |
+
};
|
| 1881 |
+
};
|
| 1882 |
+
|
| 1883 |
+
// src/listenerMiddleware/index.ts
|
| 1884 |
+
var {
|
| 1885 |
+
assign
|
| 1886 |
+
} = Object;
|
| 1887 |
+
var INTERNAL_NIL_TOKEN = {};
|
| 1888 |
+
var alm = "listenerMiddleware";
|
| 1889 |
+
var createFork = (parentAbortSignal, parentBlockingPromises) => {
|
| 1890 |
+
const linkControllers = (controller) => addAbortSignalListener(parentAbortSignal, () => abortControllerWithReason(controller, parentAbortSignal.reason));
|
| 1891 |
+
return (taskExecutor, opts) => {
|
| 1892 |
+
assertFunction(taskExecutor, "taskExecutor");
|
| 1893 |
+
const childAbortController = new AbortController();
|
| 1894 |
+
linkControllers(childAbortController);
|
| 1895 |
+
const result = runTask(async () => {
|
| 1896 |
+
validateActive(parentAbortSignal);
|
| 1897 |
+
validateActive(childAbortController.signal);
|
| 1898 |
+
const result2 = await taskExecutor({
|
| 1899 |
+
pause: createPause(childAbortController.signal),
|
| 1900 |
+
delay: createDelay(childAbortController.signal),
|
| 1901 |
+
signal: childAbortController.signal
|
| 1902 |
+
});
|
| 1903 |
+
validateActive(childAbortController.signal);
|
| 1904 |
+
return result2;
|
| 1905 |
+
}, () => abortControllerWithReason(childAbortController, taskCompleted));
|
| 1906 |
+
if (opts?.autoJoin) {
|
| 1907 |
+
parentBlockingPromises.push(result.catch(noop2));
|
| 1908 |
+
}
|
| 1909 |
+
return {
|
| 1910 |
+
result: createPause(parentAbortSignal)(result),
|
| 1911 |
+
cancel() {
|
| 1912 |
+
abortControllerWithReason(childAbortController, taskCancelled);
|
| 1913 |
+
}
|
| 1914 |
+
};
|
| 1915 |
+
};
|
| 1916 |
+
};
|
| 1917 |
+
var createTakePattern = (startListening, signal) => {
|
| 1918 |
+
const take = async (predicate, timeout) => {
|
| 1919 |
+
validateActive(signal);
|
| 1920 |
+
let unsubscribe = () => {
|
| 1921 |
+
};
|
| 1922 |
+
const tuplePromise = new Promise((resolve, reject) => {
|
| 1923 |
+
let stopListening = startListening({
|
| 1924 |
+
predicate,
|
| 1925 |
+
effect: (action, listenerApi) => {
|
| 1926 |
+
listenerApi.unsubscribe();
|
| 1927 |
+
resolve([action, listenerApi.getState(), listenerApi.getOriginalState()]);
|
| 1928 |
+
}
|
| 1929 |
+
});
|
| 1930 |
+
unsubscribe = () => {
|
| 1931 |
+
stopListening();
|
| 1932 |
+
reject();
|
| 1933 |
+
};
|
| 1934 |
+
});
|
| 1935 |
+
const promises = [tuplePromise];
|
| 1936 |
+
if (timeout != null) {
|
| 1937 |
+
promises.push(new Promise((resolve) => setTimeout(resolve, timeout, null)));
|
| 1938 |
+
}
|
| 1939 |
+
try {
|
| 1940 |
+
const output = await raceWithSignal(signal, Promise.race(promises));
|
| 1941 |
+
validateActive(signal);
|
| 1942 |
+
return output;
|
| 1943 |
+
} finally {
|
| 1944 |
+
unsubscribe();
|
| 1945 |
+
}
|
| 1946 |
+
};
|
| 1947 |
+
return (predicate, timeout) => catchRejection(take(predicate, timeout));
|
| 1948 |
+
};
|
| 1949 |
+
var getListenerEntryPropsFrom = (options) => {
|
| 1950 |
+
let {
|
| 1951 |
+
type,
|
| 1952 |
+
actionCreator,
|
| 1953 |
+
matcher,
|
| 1954 |
+
predicate,
|
| 1955 |
+
effect
|
| 1956 |
+
} = options;
|
| 1957 |
+
if (type) {
|
| 1958 |
+
predicate = createAction(type).match;
|
| 1959 |
+
} else if (actionCreator) {
|
| 1960 |
+
type = actionCreator.type;
|
| 1961 |
+
predicate = actionCreator.match;
|
| 1962 |
+
} else if (matcher) {
|
| 1963 |
+
predicate = matcher;
|
| 1964 |
+
} else if (predicate) {
|
| 1965 |
+
} else {
|
| 1966 |
+
throw new Error(false ? _formatProdErrorMessage(21) : "Creating or removing a listener requires one of the known fields for matching an action");
|
| 1967 |
+
}
|
| 1968 |
+
assertFunction(effect, "options.listener");
|
| 1969 |
+
return {
|
| 1970 |
+
predicate,
|
| 1971 |
+
type,
|
| 1972 |
+
effect
|
| 1973 |
+
};
|
| 1974 |
+
};
|
| 1975 |
+
var createListenerEntry = /* @__PURE__ */ assign((options) => {
|
| 1976 |
+
const {
|
| 1977 |
+
type,
|
| 1978 |
+
predicate,
|
| 1979 |
+
effect
|
| 1980 |
+
} = getListenerEntryPropsFrom(options);
|
| 1981 |
+
const entry = {
|
| 1982 |
+
id: nanoid(),
|
| 1983 |
+
effect,
|
| 1984 |
+
type,
|
| 1985 |
+
predicate,
|
| 1986 |
+
pending: /* @__PURE__ */ new Set(),
|
| 1987 |
+
unsubscribe: () => {
|
| 1988 |
+
throw new Error(false ? _formatProdErrorMessage2(22) : "Unsubscribe not initialized");
|
| 1989 |
+
}
|
| 1990 |
+
};
|
| 1991 |
+
return entry;
|
| 1992 |
+
}, {
|
| 1993 |
+
withTypes: () => createListenerEntry
|
| 1994 |
+
});
|
| 1995 |
+
var findListenerEntry = (listenerMap, options) => {
|
| 1996 |
+
const {
|
| 1997 |
+
type,
|
| 1998 |
+
effect,
|
| 1999 |
+
predicate
|
| 2000 |
+
} = getListenerEntryPropsFrom(options);
|
| 2001 |
+
return Array.from(listenerMap.values()).find((entry) => {
|
| 2002 |
+
const matchPredicateOrType = typeof type === "string" ? entry.type === type : entry.predicate === predicate;
|
| 2003 |
+
return matchPredicateOrType && entry.effect === effect;
|
| 2004 |
+
});
|
| 2005 |
+
};
|
| 2006 |
+
var cancelActiveListeners = (entry) => {
|
| 2007 |
+
entry.pending.forEach((controller) => {
|
| 2008 |
+
abortControllerWithReason(controller, listenerCancelled);
|
| 2009 |
+
});
|
| 2010 |
+
};
|
| 2011 |
+
var createClearListenerMiddleware = (listenerMap) => {
|
| 2012 |
+
return () => {
|
| 2013 |
+
listenerMap.forEach(cancelActiveListeners);
|
| 2014 |
+
listenerMap.clear();
|
| 2015 |
+
};
|
| 2016 |
+
};
|
| 2017 |
+
var safelyNotifyError = (errorHandler, errorToNotify, errorInfo) => {
|
| 2018 |
+
try {
|
| 2019 |
+
errorHandler(errorToNotify, errorInfo);
|
| 2020 |
+
} catch (errorHandlerError) {
|
| 2021 |
+
setTimeout(() => {
|
| 2022 |
+
throw errorHandlerError;
|
| 2023 |
+
}, 0);
|
| 2024 |
+
}
|
| 2025 |
+
};
|
| 2026 |
+
var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
|
| 2027 |
+
withTypes: () => addListener
|
| 2028 |
+
});
|
| 2029 |
+
var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
|
| 2030 |
+
var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
|
| 2031 |
+
withTypes: () => removeListener
|
| 2032 |
+
});
|
| 2033 |
+
var defaultErrorHandler = (...args) => {
|
| 2034 |
+
console.error(`${alm}/error`, ...args);
|
| 2035 |
+
};
|
| 2036 |
+
var createListenerMiddleware = (middlewareOptions = {}) => {
|
| 2037 |
+
const listenerMap = /* @__PURE__ */ new Map();
|
| 2038 |
+
const {
|
| 2039 |
+
extra,
|
| 2040 |
+
onError = defaultErrorHandler
|
| 2041 |
+
} = middlewareOptions;
|
| 2042 |
+
assertFunction(onError, "onError");
|
| 2043 |
+
const insertEntry = (entry) => {
|
| 2044 |
+
entry.unsubscribe = () => listenerMap.delete(entry.id);
|
| 2045 |
+
listenerMap.set(entry.id, entry);
|
| 2046 |
+
return (cancelOptions) => {
|
| 2047 |
+
entry.unsubscribe();
|
| 2048 |
+
if (cancelOptions?.cancelActive) {
|
| 2049 |
+
cancelActiveListeners(entry);
|
| 2050 |
+
}
|
| 2051 |
+
};
|
| 2052 |
+
};
|
| 2053 |
+
const startListening = (options) => {
|
| 2054 |
+
const entry = findListenerEntry(listenerMap, options) ?? createListenerEntry(options);
|
| 2055 |
+
return insertEntry(entry);
|
| 2056 |
+
};
|
| 2057 |
+
assign(startListening, {
|
| 2058 |
+
withTypes: () => startListening
|
| 2059 |
+
});
|
| 2060 |
+
const stopListening = (options) => {
|
| 2061 |
+
const entry = findListenerEntry(listenerMap, options);
|
| 2062 |
+
if (entry) {
|
| 2063 |
+
entry.unsubscribe();
|
| 2064 |
+
if (options.cancelActive) {
|
| 2065 |
+
cancelActiveListeners(entry);
|
| 2066 |
+
}
|
| 2067 |
+
}
|
| 2068 |
+
return !!entry;
|
| 2069 |
+
};
|
| 2070 |
+
assign(stopListening, {
|
| 2071 |
+
withTypes: () => stopListening
|
| 2072 |
+
});
|
| 2073 |
+
const notifyListener = async (entry, action, api, getOriginalState) => {
|
| 2074 |
+
const internalTaskController = new AbortController();
|
| 2075 |
+
const take = createTakePattern(startListening, internalTaskController.signal);
|
| 2076 |
+
const autoJoinPromises = [];
|
| 2077 |
+
try {
|
| 2078 |
+
entry.pending.add(internalTaskController);
|
| 2079 |
+
await Promise.resolve(entry.effect(
|
| 2080 |
+
action,
|
| 2081 |
+
// Use assign() rather than ... to avoid extra helper functions added to bundle
|
| 2082 |
+
assign({}, api, {
|
| 2083 |
+
getOriginalState,
|
| 2084 |
+
condition: (predicate, timeout) => take(predicate, timeout).then(Boolean),
|
| 2085 |
+
take,
|
| 2086 |
+
delay: createDelay(internalTaskController.signal),
|
| 2087 |
+
pause: createPause(internalTaskController.signal),
|
| 2088 |
+
extra,
|
| 2089 |
+
signal: internalTaskController.signal,
|
| 2090 |
+
fork: createFork(internalTaskController.signal, autoJoinPromises),
|
| 2091 |
+
unsubscribe: entry.unsubscribe,
|
| 2092 |
+
subscribe: () => {
|
| 2093 |
+
listenerMap.set(entry.id, entry);
|
| 2094 |
+
},
|
| 2095 |
+
cancelActiveListeners: () => {
|
| 2096 |
+
entry.pending.forEach((controller, _, set) => {
|
| 2097 |
+
if (controller !== internalTaskController) {
|
| 2098 |
+
abortControllerWithReason(controller, listenerCancelled);
|
| 2099 |
+
set.delete(controller);
|
| 2100 |
+
}
|
| 2101 |
+
});
|
| 2102 |
+
},
|
| 2103 |
+
cancel: () => {
|
| 2104 |
+
abortControllerWithReason(internalTaskController, listenerCancelled);
|
| 2105 |
+
entry.pending.delete(internalTaskController);
|
| 2106 |
+
},
|
| 2107 |
+
throwIfCancelled: () => {
|
| 2108 |
+
validateActive(internalTaskController.signal);
|
| 2109 |
+
}
|
| 2110 |
+
})
|
| 2111 |
+
));
|
| 2112 |
+
} catch (listenerError) {
|
| 2113 |
+
if (!(listenerError instanceof TaskAbortError)) {
|
| 2114 |
+
safelyNotifyError(onError, listenerError, {
|
| 2115 |
+
raisedBy: "effect"
|
| 2116 |
+
});
|
| 2117 |
+
}
|
| 2118 |
+
} finally {
|
| 2119 |
+
await Promise.all(autoJoinPromises);
|
| 2120 |
+
abortControllerWithReason(internalTaskController, listenerCompleted);
|
| 2121 |
+
entry.pending.delete(internalTaskController);
|
| 2122 |
+
}
|
| 2123 |
+
};
|
| 2124 |
+
const clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
|
| 2125 |
+
const middleware = (api) => (next) => (action) => {
|
| 2126 |
+
if (!(0, import_redux5.isAction)(action)) {
|
| 2127 |
+
return next(action);
|
| 2128 |
+
}
|
| 2129 |
+
if (addListener.match(action)) {
|
| 2130 |
+
return startListening(action.payload);
|
| 2131 |
+
}
|
| 2132 |
+
if (clearAllListeners.match(action)) {
|
| 2133 |
+
clearListenerMiddleware();
|
| 2134 |
+
return;
|
| 2135 |
+
}
|
| 2136 |
+
if (removeListener.match(action)) {
|
| 2137 |
+
return stopListening(action.payload);
|
| 2138 |
+
}
|
| 2139 |
+
let originalState = api.getState();
|
| 2140 |
+
const getOriginalState = () => {
|
| 2141 |
+
if (originalState === INTERNAL_NIL_TOKEN) {
|
| 2142 |
+
throw new Error(false ? _formatProdErrorMessage3(23) : `${alm}: getOriginalState can only be called synchronously`);
|
| 2143 |
+
}
|
| 2144 |
+
return originalState;
|
| 2145 |
+
};
|
| 2146 |
+
let result;
|
| 2147 |
+
try {
|
| 2148 |
+
result = next(action);
|
| 2149 |
+
if (listenerMap.size > 0) {
|
| 2150 |
+
const currentState = api.getState();
|
| 2151 |
+
const listenerEntries = Array.from(listenerMap.values());
|
| 2152 |
+
for (const entry of listenerEntries) {
|
| 2153 |
+
let runListener = false;
|
| 2154 |
+
try {
|
| 2155 |
+
runListener = entry.predicate(action, currentState, originalState);
|
| 2156 |
+
} catch (predicateError) {
|
| 2157 |
+
runListener = false;
|
| 2158 |
+
safelyNotifyError(onError, predicateError, {
|
| 2159 |
+
raisedBy: "predicate"
|
| 2160 |
+
});
|
| 2161 |
+
}
|
| 2162 |
+
if (!runListener) {
|
| 2163 |
+
continue;
|
| 2164 |
+
}
|
| 2165 |
+
notifyListener(entry, action, api, getOriginalState);
|
| 2166 |
+
}
|
| 2167 |
+
}
|
| 2168 |
+
} finally {
|
| 2169 |
+
originalState = INTERNAL_NIL_TOKEN;
|
| 2170 |
+
}
|
| 2171 |
+
return result;
|
| 2172 |
+
};
|
| 2173 |
+
return {
|
| 2174 |
+
middleware,
|
| 2175 |
+
startListening,
|
| 2176 |
+
stopListening,
|
| 2177 |
+
clearListeners: clearListenerMiddleware
|
| 2178 |
+
};
|
| 2179 |
+
};
|
| 2180 |
+
|
| 2181 |
+
// src/dynamicMiddleware/index.ts
|
| 2182 |
+
var import_redux6 = require("redux");
|
| 2183 |
+
var createMiddlewareEntry = (middleware) => ({
|
| 2184 |
+
middleware,
|
| 2185 |
+
applied: /* @__PURE__ */ new Map()
|
| 2186 |
+
});
|
| 2187 |
+
var matchInstance = (instanceId) => (action) => action?.meta?.instanceId === instanceId;
|
| 2188 |
+
var createDynamicMiddleware = () => {
|
| 2189 |
+
const instanceId = nanoid();
|
| 2190 |
+
const middlewareMap = /* @__PURE__ */ new Map();
|
| 2191 |
+
const withMiddleware = Object.assign(createAction("dynamicMiddleware/add", (...middlewares) => ({
|
| 2192 |
+
payload: middlewares,
|
| 2193 |
+
meta: {
|
| 2194 |
+
instanceId
|
| 2195 |
+
}
|
| 2196 |
+
})), {
|
| 2197 |
+
withTypes: () => withMiddleware
|
| 2198 |
+
});
|
| 2199 |
+
const addMiddleware = Object.assign(function addMiddleware2(...middlewares) {
|
| 2200 |
+
middlewares.forEach((middleware2) => {
|
| 2201 |
+
getOrInsertComputed(middlewareMap, middleware2, createMiddlewareEntry);
|
| 2202 |
+
});
|
| 2203 |
+
}, {
|
| 2204 |
+
withTypes: () => addMiddleware
|
| 2205 |
+
});
|
| 2206 |
+
const getFinalMiddleware = (api) => {
|
| 2207 |
+
const appliedMiddleware = Array.from(middlewareMap.values()).map((entry) => getOrInsertComputed(entry.applied, api, entry.middleware));
|
| 2208 |
+
return (0, import_redux6.compose)(...appliedMiddleware);
|
| 2209 |
+
};
|
| 2210 |
+
const isWithMiddleware = isAllOf(withMiddleware, matchInstance(instanceId));
|
| 2211 |
+
const middleware = (api) => (next) => (action) => {
|
| 2212 |
+
if (isWithMiddleware(action)) {
|
| 2213 |
+
addMiddleware(...action.payload);
|
| 2214 |
+
return api.dispatch;
|
| 2215 |
+
}
|
| 2216 |
+
return getFinalMiddleware(api)(next)(action);
|
| 2217 |
+
};
|
| 2218 |
+
return {
|
| 2219 |
+
middleware,
|
| 2220 |
+
addMiddleware,
|
| 2221 |
+
withMiddleware,
|
| 2222 |
+
instanceId
|
| 2223 |
+
};
|
| 2224 |
+
};
|
| 2225 |
+
|
| 2226 |
+
// src/combineSlices.ts
|
| 2227 |
+
var import_redux7 = require("redux");
|
| 2228 |
+
var isSliceLike = (maybeSliceLike) => "reducerPath" in maybeSliceLike && typeof maybeSliceLike.reducerPath === "string";
|
| 2229 |
+
var getReducers = (slices) => slices.flatMap((sliceOrMap) => isSliceLike(sliceOrMap) ? [[sliceOrMap.reducerPath, sliceOrMap.reducer]] : Object.entries(sliceOrMap));
|
| 2230 |
+
var ORIGINAL_STATE = Symbol.for("rtk-state-proxy-original");
|
| 2231 |
+
var isStateProxy = (value) => !!value && !!value[ORIGINAL_STATE];
|
| 2232 |
+
var stateProxyMap = /* @__PURE__ */ new WeakMap();
|
| 2233 |
+
var createStateProxy = (state, reducerMap, initialStateCache) => getOrInsertComputed(stateProxyMap, state, () => new Proxy(state, {
|
| 2234 |
+
get: (target, prop, receiver) => {
|
| 2235 |
+
if (prop === ORIGINAL_STATE) return target;
|
| 2236 |
+
const result = Reflect.get(target, prop, receiver);
|
| 2237 |
+
if (typeof result === "undefined") {
|
| 2238 |
+
const cached = initialStateCache[prop];
|
| 2239 |
+
if (typeof cached !== "undefined") return cached;
|
| 2240 |
+
const reducer = reducerMap[prop];
|
| 2241 |
+
if (reducer) {
|
| 2242 |
+
const reducerResult = reducer(void 0, {
|
| 2243 |
+
type: nanoid()
|
| 2244 |
+
});
|
| 2245 |
+
if (typeof reducerResult === "undefined") {
|
| 2246 |
+
throw new Error(false ? _formatProdErrorMessage(24) : `The slice reducer for key "${prop.toString()}" returned undefined when called for selector(). If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
|
| 2247 |
+
}
|
| 2248 |
+
initialStateCache[prop] = reducerResult;
|
| 2249 |
+
return reducerResult;
|
| 2250 |
+
}
|
| 2251 |
+
}
|
| 2252 |
+
return result;
|
| 2253 |
+
}
|
| 2254 |
+
}));
|
| 2255 |
+
var original = (state) => {
|
| 2256 |
+
if (!isStateProxy(state)) {
|
| 2257 |
+
throw new Error(false ? _formatProdErrorMessage2(25) : "original must be used on state Proxy");
|
| 2258 |
+
}
|
| 2259 |
+
return state[ORIGINAL_STATE];
|
| 2260 |
+
};
|
| 2261 |
+
var emptyObject = {};
|
| 2262 |
+
var noopReducer = (state = emptyObject) => state;
|
| 2263 |
+
function combineSlices(...slices) {
|
| 2264 |
+
const reducerMap = Object.fromEntries(getReducers(slices));
|
| 2265 |
+
const getReducer = () => Object.keys(reducerMap).length ? (0, import_redux7.combineReducers)(reducerMap) : noopReducer;
|
| 2266 |
+
let reducer = getReducer();
|
| 2267 |
+
function combinedReducer(state, action) {
|
| 2268 |
+
return reducer(state, action);
|
| 2269 |
+
}
|
| 2270 |
+
combinedReducer.withLazyLoadedSlices = () => combinedReducer;
|
| 2271 |
+
const initialStateCache = {};
|
| 2272 |
+
const inject = (slice, config = {}) => {
|
| 2273 |
+
const {
|
| 2274 |
+
reducerPath,
|
| 2275 |
+
reducer: reducerToInject
|
| 2276 |
+
} = slice;
|
| 2277 |
+
const currentReducer = reducerMap[reducerPath];
|
| 2278 |
+
if (!config.overrideExisting && currentReducer && currentReducer !== reducerToInject) {
|
| 2279 |
+
if (typeof process !== "undefined" && true) {
|
| 2280 |
+
console.error(`called \`inject\` to override already-existing reducer ${reducerPath} without specifying \`overrideExisting: true\``);
|
| 2281 |
+
}
|
| 2282 |
+
return combinedReducer;
|
| 2283 |
+
}
|
| 2284 |
+
if (config.overrideExisting && currentReducer !== reducerToInject) {
|
| 2285 |
+
delete initialStateCache[reducerPath];
|
| 2286 |
+
}
|
| 2287 |
+
reducerMap[reducerPath] = reducerToInject;
|
| 2288 |
+
reducer = getReducer();
|
| 2289 |
+
return combinedReducer;
|
| 2290 |
+
};
|
| 2291 |
+
const selector = Object.assign(function makeSelector(selectorFn, selectState) {
|
| 2292 |
+
return function selector2(state, ...args) {
|
| 2293 |
+
return selectorFn(createStateProxy(selectState ? selectState(state, ...args) : state, reducerMap, initialStateCache), ...args);
|
| 2294 |
+
};
|
| 2295 |
+
}, {
|
| 2296 |
+
original
|
| 2297 |
+
});
|
| 2298 |
+
return Object.assign(combinedReducer, {
|
| 2299 |
+
inject,
|
| 2300 |
+
selector
|
| 2301 |
+
});
|
| 2302 |
+
}
|
| 2303 |
+
|
| 2304 |
+
// src/formatProdErrorMessage.ts
|
| 2305 |
+
function formatProdErrorMessage(code) {
|
| 2306 |
+
return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
| 2307 |
+
}
|
| 2308 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 2309 |
+
0 && (module.exports = {
|
| 2310 |
+
ReducerType,
|
| 2311 |
+
SHOULD_AUTOBATCH,
|
| 2312 |
+
TaskAbortError,
|
| 2313 |
+
Tuple,
|
| 2314 |
+
addListener,
|
| 2315 |
+
asyncThunkCreator,
|
| 2316 |
+
autoBatchEnhancer,
|
| 2317 |
+
buildCreateSlice,
|
| 2318 |
+
clearAllListeners,
|
| 2319 |
+
combineSlices,
|
| 2320 |
+
configureStore,
|
| 2321 |
+
createAction,
|
| 2322 |
+
createActionCreatorInvariantMiddleware,
|
| 2323 |
+
createAsyncThunk,
|
| 2324 |
+
createDraftSafeSelector,
|
| 2325 |
+
createDraftSafeSelectorCreator,
|
| 2326 |
+
createDynamicMiddleware,
|
| 2327 |
+
createEntityAdapter,
|
| 2328 |
+
createImmutableStateInvariantMiddleware,
|
| 2329 |
+
createListenerMiddleware,
|
| 2330 |
+
createNextState,
|
| 2331 |
+
createReducer,
|
| 2332 |
+
createSelector,
|
| 2333 |
+
createSelectorCreator,
|
| 2334 |
+
createSerializableStateInvariantMiddleware,
|
| 2335 |
+
createSlice,
|
| 2336 |
+
current,
|
| 2337 |
+
findNonSerializableValue,
|
| 2338 |
+
formatProdErrorMessage,
|
| 2339 |
+
freeze,
|
| 2340 |
+
isActionCreator,
|
| 2341 |
+
isAllOf,
|
| 2342 |
+
isAnyOf,
|
| 2343 |
+
isAsyncThunkAction,
|
| 2344 |
+
isDraft,
|
| 2345 |
+
isFluxStandardAction,
|
| 2346 |
+
isFulfilled,
|
| 2347 |
+
isImmutableDefault,
|
| 2348 |
+
isPending,
|
| 2349 |
+
isPlain,
|
| 2350 |
+
isRejected,
|
| 2351 |
+
isRejectedWithValue,
|
| 2352 |
+
lruMemoize,
|
| 2353 |
+
miniSerializeError,
|
| 2354 |
+
nanoid,
|
| 2355 |
+
original,
|
| 2356 |
+
prepareAutoBatched,
|
| 2357 |
+
removeListener,
|
| 2358 |
+
unwrapResult,
|
| 2359 |
+
weakMapMemoize,
|
| 2360 |
+
...require("redux")
|
| 2361 |
+
});
|
| 2362 |
+
//# sourceMappingURL=redux-toolkit.development.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.development.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";var Pe=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Vt=Object.prototype.hasOwnProperty;var _t=(e,t)=>{for(var r in t)Pe(e,r,{get:t[r],enumerable:!0})},Me=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Vt.call(e,o)&&o!==r&&Pe(e,o,{get:()=>t[o],enumerable:!(n=jt(t,o))||n.enumerable});return e},w=(e,t,r)=>(Me(e,t,"default"),r&&Me(r,t,"default"));var Lt=e=>Me(Pe({},"__esModule",{value:!0}),e);var C={};_t(C,{ReducerType:()=>We,SHOULD_AUTOBATCH:()=>ce,TaskAbortError:()=>I,Tuple:()=>F,addListener:()=>Re,asyncThunkCreator:()=>lt,autoBatchEnhancer:()=>de,buildCreateSlice:()=>ze,clearAllListeners:()=>qe,combineSlices:()=>Nt,configureStore:()=>st,createAction:()=>b,createActionCreatorInvariantMiddleware:()=>Qe,createAsyncThunk:()=>ye,createDraftSafeSelector:()=>ne,createDraftSafeSelectorCreator:()=>be,createDynamicMiddleware:()=>Dt,createEntityAdapter:()=>Tt,createImmutableStateInvariantMiddleware:()=>Ze,createListenerMiddleware:()=>It,createNextState:()=>N.produce,createReducer:()=>le,createSelector:()=>W.createSelector,createSelectorCreator:()=>W.createSelectorCreator,createSerializableStateInvariantMiddleware:()=>nt,createSlice:()=>pt,current:()=>N.current,findNonSerializableValue:()=>Ne,formatProdErrorMessage:()=>x,freeze:()=>N.freeze,isActionCreator:()=>oe,isAllOf:()=>B,isAnyOf:()=>V,isAsyncThunkAction:()=>_e,isDraft:()=>N.isDraft,isFluxStandardAction:()=>ae,isFulfilled:()=>Ve,isImmutableDefault:()=>Ye,isPending:()=>je,isPlain:()=>Oe,isRejected:()=>$,isRejectedWithValue:()=>Fe,lruMemoize:()=>W.lruMemoize,miniSerializeError:()=>Le,nanoid:()=>O,original:()=>N.original,prepareAutoBatched:()=>at,removeListener:()=>we,unwrapResult:()=>Ue,weakMapMemoize:()=>W.weakMapMemoize});module.exports=Lt(C);w(C,require("redux"),module.exports);var N=require("immer"),W=require("reselect");var ee=require("immer"),te=require("reselect"),be=(...e)=>{let t=(0,te.createSelectorCreator)(...e),r=Object.assign((...n)=>{let o=t(...n),a=(s,...y)=>o((0,ee.isDraft)(s)?(0,ee.current)(s):s,...y);return Object.assign(a,o),a},{withTypes:()=>r});return r},ne=be(te.weakMapMemoize);var D=require("redux");var Ie=require("redux"),Je=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Ie.compose:Ie.compose.apply(null,arguments)},xn=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}};var se=require("redux-thunk");var ve=require("redux");var re=e=>e&&typeof e.match=="function";function b(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(x(0));return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>(0,ve.isAction)(n)&&n.type===e,r}function oe(e){return typeof e=="function"&&"type"in e&&re(e)}function ae(e){return(0,ve.isAction)(e)&&Object.keys(e).every(Ut)}function Ut(e){return["type","payload","error","meta"].indexOf(e)>-1}function Wt(e){let t=e?`${e}`.split("/"):[],r=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched.
|
| 2 |
+
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${r}())\` instead of \`dispatch(${r})\`. This is necessary even if the action has no payload.`}function Qe(e={}){return()=>r=>n=>r(n)}var ie=require("immer");var F=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function De(e){return(0,ie.isDraftable)(e)?(0,ie.produce)(e,()=>{}):e}function v(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function Ye(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function Ze(e={}){if(1)return()=>n=>o=>n(o);var t,r}var et=require("redux");function Oe(e){let t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||(0,et.isPlainObject)(e)}function Ne(e,t="",r=Oe,n,o=[],a){let s;if(!r(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||a?.has(e))return!1;let y=n!=null?n(e):Object.entries(e),c=o.length>0;for(let[l,i]of y){let d=t?t+"."+l:l;if(!(c&&o.some(g=>g instanceof RegExp?g.test(d):d===g))){if(!r(i))return{keyPath:d,value:i};if(typeof i=="object"&&(s=Ne(i,d,r,n,o,a),s))return s}}return a&&tt(e)&&a.add(e),!1}function tt(e){if(!Object.isFrozen(e))return!1;for(let t of Object.values(e))if(!(typeof t!="object"||t===null)&&!tt(t))return!1;return!0}function nt(e={}){return()=>t=>r=>t(r)}function zt(e){return typeof e=="boolean"}var rt=()=>function(t){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:a=!0}=t??{},s=new F;return r&&(zt(r)?s.push(se.thunk):s.push((0,se.withExtraArgument)(r.extraArgument))),s};var ce="RTK_autoBatch",at=()=>e=>({payload:e,meta:{[ce]:!0}}),ot=e=>t=>{setTimeout(t,e)},de=(e={type:"raf"})=>t=>(...r)=>{let n=t(...r),o=!0,a=!1,s=!1,y=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:ot(10):e.type==="callback"?e.queueNotification:ot(e.timeout),l=()=>{s=!1,a&&(a=!1,y.forEach(i=>i()))};return Object.assign({},n,{subscribe(i){let d=()=>o&&i(),T=n.subscribe(d);return y.add(i),()=>{T(),y.delete(i)}},dispatch(i){try{return o=!i?.meta?.[ce],a=!o,a&&(s||(s=!0,c(l))),n.dispatch(i)}finally{o=!0}}})};var it=e=>function(r){let{autoBatch:n=!0}=r??{},o=new F(e);return n&&o.push(de(typeof n=="object"?n:void 0)),o};function st(e){let t=rt(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:a=!0,preloadedState:s=void 0,enhancers:y=void 0}=e||{},c;if(typeof r=="function")c=r;else if((0,D.isPlainObject)(r))c=(0,D.combineReducers)(r);else throw new Error(x(1));let l;typeof n=="function"?l=n(t):l=t();let i=D.compose;o&&(i=Je({trace:!1,...typeof o=="object"&&o}));let d=(0,D.applyMiddleware)(...l),T=it(d),g=typeof y=="function"?y(T):T(),p=i(...g);return(0,D.createStore)(c,s,p)}var G=require("immer");function ue(e){let t={},r=[],n,o={addCase(a,s){let y=typeof a=="string"?a:a.type;if(!y)throw new Error(x(28));if(y in t)throw new Error(x(29));return t[y]=s,o},addMatcher(a,s){return r.push({matcher:a,reducer:s}),o},addDefaultCase(a){return n=a,o}};return e(o),[t,r,n]}function Gt(e){return typeof e=="function"}function le(e,t){let[r,n,o]=ue(t),a;if(Gt(e))a=()=>De(e());else{let y=De(e);a=()=>y}function s(y=a(),c){let l=[r[c.type],...n.filter(({matcher:i})=>i(c)).map(({reducer:i})=>i)];return l.filter(i=>!!i).length===0&&(l=[o]),l.reduce((i,d)=>{if(d)if((0,G.isDraft)(i)){let g=d(i,c);return g===void 0?i:g}else{if((0,G.isDraftable)(i))return(0,G.produce)(i,T=>d(T,c));{let T=d(i,c);if(T===void 0){if(i===null)return i;throw Error("A case reducer on a non-draftable value must not return undefined")}return T}}return i},y)}return s.getInitialState=a,s}var ct=(e,t)=>re(e)?e.match(t):e(t);function V(...e){return t=>e.some(r=>ct(r,t))}function B(...e){return t=>e.every(r=>ct(r,t))}function pe(e,t){if(!e||!e.meta)return!1;let r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function X(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function je(...e){return e.length===0?t=>pe(t,["pending"]):X(e)?V(...e.map(t=>t.pending)):je()(e[0])}function $(...e){return e.length===0?t=>pe(t,["rejected"]):X(e)?V(...e.map(t=>t.rejected)):$()(e[0])}function Fe(...e){let t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?B($(...e),t):X(e)?B($(...e),t):Fe()(e[0])}function Ve(...e){return e.length===0?t=>pe(t,["fulfilled"]):X(e)?V(...e.map(t=>t.fulfilled)):Ve()(e[0])}function _e(...e){return e.length===0?t=>pe(t,["pending","fulfilled","rejected"]):X(e)?V(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):_e()(e[0])}var Bt="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",O=(e=21)=>{let t="",r=e;for(;r--;)t+=Bt[Math.random()*64|0];return t};var Kt=["name","message","stack","code"],J=class{constructor(t,r){this.payload=t;this.meta=r}_type},fe=class{constructor(t,r){this.payload=t;this.meta=r}_type},Le=e=>{if(typeof e=="object"&&e!==null){let t={};for(let r of Kt)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},dt="External signal was aborted",ye=(()=>{function e(t,r,n){let o=b(t+"/fulfilled",(c,l,i,d)=>({payload:c,meta:{...d||{},arg:i,requestId:l,requestStatus:"fulfilled"}})),a=b(t+"/pending",(c,l,i)=>({payload:void 0,meta:{...i||{},arg:l,requestId:c,requestStatus:"pending"}})),s=b(t+"/rejected",(c,l,i,d,T)=>({payload:d,error:(n&&n.serializeError||Le)(c||"Rejected"),meta:{...T||{},arg:i,requestId:l,rejectedWithValue:!!d,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"}}));function y(c,{signal:l}={}){return(i,d,T)=>{let g=n?.idGenerator?n.idGenerator(c):O(),p=new AbortController,h,u;function f(A){u=A,p.abort()}l&&(l.aborted?f(dt):l.addEventListener("abort",()=>f(dt),{once:!0}));let k=async function(){let A;try{let S=n?.condition?.(c,{getState:d,extra:T});if(Ht(S)&&(S=await S),S===!1||p.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let P=new Promise((E,R)=>{h=()=>{R({name:"AbortError",message:u||"Aborted"})},p.signal.addEventListener("abort",h)});i(a(g,c,n?.getPendingMeta?.({requestId:g,arg:c},{getState:d,extra:T}))),A=await Promise.race([P,Promise.resolve(r(c,{dispatch:i,getState:d,extra:T,requestId:g,signal:p.signal,abort:f,rejectWithValue:(E,R)=>new J(E,R),fulfillWithValue:(E,R)=>new fe(E,R)})).then(E=>{if(E instanceof J)throw E;return E instanceof fe?o(E.payload,g,c,E.meta):o(E,g,c)})])}catch(S){A=S instanceof J?s(null,g,c,S.payload,S.meta):s(S,g,c)}finally{h&&p.signal.removeEventListener("abort",h)}return n&&!n.dispatchConditionRejection&&s.match(A)&&A.meta.condition||i(A),A}();return Object.assign(k,{abort:f,requestId:g,arg:c,unwrap(){return k.then(Ue)}})}}return Object.assign(y,{pending:a,rejected:s,fulfilled:o,settled:V(s,o),typePrefix:t})}return e.withTypes=()=>e,e})();function Ue(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function Ht(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var ut=Symbol.for("rtk-slice-createasyncthunk"),lt={[ut]:ye},We=(n=>(n.reducer="reducer",n.reducerWithPrepare="reducerWithPrepare",n.asyncThunk="asyncThunk",n))(We||{});function qt(e,t){return`${e}/${t}`}function ze({creators:e}={}){let t=e?.asyncThunk?.[ut];return function(n){let{name:o,reducerPath:a=o}=n;if(!o)throw new Error(x(11));typeof process<"u";let s=(typeof n.reducers=="function"?n.reducers(Xt()):n.reducers)||{},y=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(A,m){let S=typeof A=="string"?A:A.type;if(!S)throw new Error(x(12));if(S in c.sliceCaseReducersByType)throw new Error(x(13));return c.sliceCaseReducersByType[S]=m,l},addMatcher(A,m){return c.sliceMatchers.push({matcher:A,reducer:m}),l},exposeAction(A,m){return c.actionCreators[A]=m,l},exposeCaseReducer(A,m){return c.sliceCaseReducersByName[A]=m,l}};y.forEach(A=>{let m=s[A],S={reducerName:A,type:qt(o,A),createNotation:typeof n.reducers=="function"};Qt(m)?Zt(S,m,l,t):Jt(S,m,l)});function i(){let[A={},m=[],S=void 0]=typeof n.extraReducers=="function"?ue(n.extraReducers):[n.extraReducers],P={...A,...c.sliceCaseReducersByType};return le(n.initialState,E=>{for(let R in P)E.addCase(R,P[R]);for(let R of c.sliceMatchers)E.addMatcher(R.matcher,R.reducer);for(let R of m)E.addMatcher(R.matcher,R.reducer);S&&E.addDefaultCase(S)})}let d=A=>A,T=new Map,g=new WeakMap,p;function h(A,m){return p||(p=i()),p(A,m)}function u(){return p||(p=i()),p.getInitialState()}function f(A,m=!1){function S(E){let R=E[A];return typeof R>"u"&&m&&(R=v(g,S,u)),R}function P(E=d){let R=v(T,m,()=>new WeakMap);return v(R,E,()=>{let q={};for(let[Z,z]of Object.entries(n.selectors??{}))q[Z]=$t(z,E,()=>v(g,E,u),m);return q})}return{reducerPath:A,getSelectors:P,get selectors(){return P(S)},selectSlice:S}}let k={name:o,reducer:h,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:u,...f(a),injectInto(A,{reducerPath:m,...S}={}){let P=m??a;return A.inject({reducerPath:P,reducer:h},S),{...k,...f(P,!0)}}};return k}}function $t(e,t,r,n){function o(a,...s){let y=t(a);return typeof y>"u"&&n&&(y=r()),e(y,...s)}return o.unwrapped=e,o}var pt=ze();function Xt(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function Jt({type:e,reducerName:t,createNotation:r},n,o){let a,s;if("reducer"in n){if(r&&!Yt(n))throw new Error(x(17));a=n.reducer,s=n.prepare}else a=n;o.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,s?b(e,s):b(e))}function Qt(e){return e._reducerDefinitionType==="asyncThunk"}function Yt(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Zt({type:e,reducerName:t},r,n,o){if(!o)throw new Error(x(18));let{payloadCreator:a,fulfilled:s,pending:y,rejected:c,settled:l,options:i}=r,d=o(e,a,i);n.exposeAction(t,d),s&&n.addCase(d.fulfilled,s),y&&n.addCase(d.pending,y),c&&n.addCase(d.rejected,c),l&&n.addMatcher(d.settled,l),n.exposeCaseReducer(t,{fulfilled:s||he,pending:y||he,rejected:c||he,settled:l||he})}function he(){}function en(){return{ids:[],entities:{}}}function ft(e){function t(r={},n){let o=Object.assign(en(),r);return n?e.setAll(o,n):o}return{getInitialState:t}}function yt(){function e(t,r={}){let{createSelector:n=ne}=r,o=d=>d.ids,a=d=>d.entities,s=n(o,a,(d,T)=>d.map(g=>T[g])),y=(d,T)=>T,c=(d,T)=>d[T],l=n(o,d=>d.length);if(!t)return{selectIds:o,selectEntities:a,selectAll:s,selectTotal:l,selectById:n(a,y,c)};let i=n(t,a);return{selectIds:n(t,o),selectEntities:i,selectAll:n(t,s),selectTotal:n(t,l),selectById:n(i,y,c)}}return{getSelectors:e}}var Ae=require("immer");var tn=Ae.isDraft;function ht(e){let t=M((r,n)=>e(n));return function(n){return t(n,void 0)}}function M(e){return function(r,n){function o(s){return ae(s)}let a=s=>{o(n)?e(n.payload,s):e(n,s)};return tn(r)?(a(r),r):(0,Ae.produce)(r,a)}}var Te=require("immer");function _(e,t){return t(e)}function j(e){return Array.isArray(e)||(e=Object.values(e)),e}function Q(e){return(0,Te.isDraft)(e)?(0,Te.current)(e):e}function me(e,t,r){e=j(e);let n=Q(r.ids),o=new Set(n),a=[],s=new Set([]),y=[];for(let c of e){let l=_(c,t);o.has(l)||s.has(l)?y.push({id:l,changes:c}):(s.add(l),a.push(c))}return[a,y,n]}function ge(e){function t(p,h){let u=_(p,e);u in h.entities||(h.ids.push(u),h.entities[u]=p)}function r(p,h){p=j(p);for(let u of p)t(u,h)}function n(p,h){let u=_(p,e);u in h.entities||h.ids.push(u),h.entities[u]=p}function o(p,h){p=j(p);for(let u of p)n(u,h)}function a(p,h){p=j(p),h.ids=[],h.entities={},r(p,h)}function s(p,h){return y([p],h)}function y(p,h){let u=!1;p.forEach(f=>{f in h.entities&&(delete h.entities[f],u=!0)}),u&&(h.ids=h.ids.filter(f=>f in h.entities))}function c(p){Object.assign(p,{ids:[],entities:{}})}function l(p,h,u){let f=u.entities[h.id];if(f===void 0)return!1;let k=Object.assign({},f,h.changes),A=_(k,e),m=A!==h.id;return m&&(p[h.id]=A,delete u.entities[h.id]),u.entities[A]=k,m}function i(p,h){return d([p],h)}function d(p,h){let u={},f={};p.forEach(A=>{A.id in h.entities&&(f[A.id]={id:A.id,changes:{...f[A.id]?.changes,...A.changes}})}),p=Object.values(f),p.length>0&&p.filter(m=>l(u,m,h)).length>0&&(h.ids=Object.values(h.entities).map(m=>_(m,e)))}function T(p,h){return g([p],h)}function g(p,h){let[u,f]=me(p,e,h);r(u,h),d(f,h)}return{removeAll:ht(c),addOne:M(t),addMany:M(r),setOne:M(n),setMany:M(o),setAll:M(a),updateOne:M(i),updateMany:M(d),upsertOne:M(T),upsertMany:M(g),removeOne:M(s),removeMany:M(y)}}function nn(e,t,r){let n=0,o=e.length;for(;n<o;){let a=n+o>>>1,s=e[a];r(t,s)>=0?n=a+1:o=a}return n}function rn(e,t,r){let n=nn(e,t,r);return e.splice(n,0,t),e}function At(e,t){let{removeOne:r,removeMany:n,removeAll:o}=ge(e);function a(u,f){return s([u],f)}function s(u,f,k){u=j(u);let A=new Set(k??Q(f.ids)),m=u.filter(S=>!A.has(_(S,e)));m.length!==0&&h(f,m)}function y(u,f){return c([u],f)}function c(u,f){if(u=j(u),u.length!==0){for(let k of u)delete f.entities[e(k)];h(f,u)}}function l(u,f){u=j(u),f.entities={},f.ids=[],s(u,f,[])}function i(u,f){return d([u],f)}function d(u,f){let k=!1,A=!1;for(let m of u){let S=f.entities[m.id];if(!S)continue;k=!0,Object.assign(S,m.changes);let P=e(S);if(m.id!==P){A=!0,delete f.entities[m.id];let E=f.ids.indexOf(m.id);f.ids[E]=P,f.entities[P]=S}}k&&h(f,[],k,A)}function T(u,f){return g([u],f)}function g(u,f){let[k,A,m]=me(u,e,f);k.length&&s(k,f,m),A.length&&d(A,f)}function p(u,f){if(u.length!==f.length)return!1;for(let k=0;k<u.length;k++)if(u[k]!==f[k])return!1;return!0}let h=(u,f,k,A)=>{let m=Q(u.entities),S=Q(u.ids),P=u.entities,E=S;A&&(E=new Set(S));let R=[];for(let z of E){let Xe=m[z];Xe&&R.push(Xe)}let q=R.length===0;for(let z of f)P[e(z)]=z,q||rn(R,z,t);q?R=f.slice().sort(t):k&&R.sort(t);let Z=R.map(e);p(S,Z)||(u.ids=Z)};return{removeOne:r,removeMany:n,removeAll:o,addOne:M(a),updateOne:M(i),upsertOne:M(T),setOne:M(y),setMany:M(c),setAll:M(l),addMany:M(s),updateMany:M(d),upsertMany:M(g)}}function Tt(e={}){let{selectId:t,sortComparer:r}={sortComparer:!1,selectId:s=>s.id,...e},n=r?At(t,r):ge(t),o=ft(n),a=yt();return{selectId:t,sortComparer:r,...o,...a,...n}}var Mt=require("redux");var on="task",mt="listener",gt="completed",Ge="cancelled",St=`task-${Ge}`,kt=`task-${gt}`,Se=`${mt}-${Ge}`,xt=`${mt}-${gt}`,I=class{constructor(t){this.code=t;this.message=`${on} ${Ge} (reason: ${t})`}name="TaskAbortError";message};var ke=(e,t)=>{if(typeof e!="function")throw new TypeError(x(32))},K=()=>{},xe=(e,t=K)=>(e.catch(t),e),Ce=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),L=(e,t)=>{let r=e.signal;r.aborted||("reason"in r||Object.defineProperty(r,"reason",{enumerable:!0,value:t,configurable:!0,writable:!0}),e.abort(t))};var U=e=>{if(e.aborted){let{reason:t}=e;throw new I(t)}};function Be(e,t){let r=K;return new Promise((n,o)=>{let a=()=>o(new I(e.reason));if(e.aborted){a();return}r=Ce(e,a),t.finally(()=>r()).then(n,o)}).finally(()=>{r=K})}var Ct=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(r){return{status:r instanceof I?"cancelled":"rejected",error:r}}finally{t?.()}},Y=e=>t=>xe(Be(e,t).then(r=>(U(e),r))),Ke=e=>{let t=Y(e);return r=>t(new Promise(n=>setTimeout(n,r)))};var{assign:H}=Object,Et={},Ee="listenerMiddleware",an=(e,t)=>{let r=n=>Ce(e,()=>L(n,e.reason));return(n,o)=>{ke(n,"taskExecutor");let a=new AbortController;r(a);let s=Ct(async()=>{U(e),U(a.signal);let y=await n({pause:Y(a.signal),delay:Ke(a.signal),signal:a.signal});return U(a.signal),y},()=>L(a,kt));return o?.autoJoin&&t.push(s.catch(K)),{result:Y(e)(s),cancel(){L(a,St)}}}},sn=(e,t)=>{let r=async(n,o)=>{U(t);let a=()=>{},y=[new Promise((c,l)=>{let i=e({predicate:n,effect:(d,T)=>{T.unsubscribe(),c([d,T.getState(),T.getOriginalState()])}});a=()=>{i(),l()}})];o!=null&&y.push(new Promise(c=>setTimeout(c,o,null)));try{let c=await Be(t,Promise.race(y));return U(t),c}finally{a()}};return(n,o)=>xe(r(n,o))},Pt=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:a}=e;if(t)o=b(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(x(21));return ke(a,"options.listener"),{predicate:o,type:t,effect:a}},bt=H(e=>{let{type:t,predicate:r,effect:n}=Pt(e);return{id:O(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(x(22))}}},{withTypes:()=>bt}),Rt=(e,t)=>{let{type:r,effect:n,predicate:o}=Pt(t);return Array.from(e.values()).find(a=>(typeof r=="string"?a.type===r:a.predicate===o)&&a.effect===n)},He=e=>{e.pending.forEach(t=>{L(t,Se)})},cn=e=>()=>{e.forEach(He),e.clear()},wt=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},Re=H(b(`${Ee}/add`),{withTypes:()=>Re}),qe=b(`${Ee}/removeAll`),we=H(b(`${Ee}/remove`),{withTypes:()=>we}),dn=(...e)=>{console.error(`${Ee}/error`,...e)},It=(e={})=>{let t=new Map,{extra:r,onError:n=dn}=e;ke(n,"onError");let o=i=>(i.unsubscribe=()=>t.delete(i.id),t.set(i.id,i),d=>{i.unsubscribe(),d?.cancelActive&&He(i)}),a=i=>{let d=Rt(t,i)??bt(i);return o(d)};H(a,{withTypes:()=>a});let s=i=>{let d=Rt(t,i);return d&&(d.unsubscribe(),i.cancelActive&&He(d)),!!d};H(s,{withTypes:()=>s});let y=async(i,d,T,g)=>{let p=new AbortController,h=sn(a,p.signal),u=[];try{i.pending.add(p),await Promise.resolve(i.effect(d,H({},T,{getOriginalState:g,condition:(f,k)=>h(f,k).then(Boolean),take:h,delay:Ke(p.signal),pause:Y(p.signal),extra:r,signal:p.signal,fork:an(p.signal,u),unsubscribe:i.unsubscribe,subscribe:()=>{t.set(i.id,i)},cancelActiveListeners:()=>{i.pending.forEach((f,k,A)=>{f!==p&&(L(f,Se),A.delete(f))})},cancel:()=>{L(p,Se),i.pending.delete(p)},throwIfCancelled:()=>{U(p.signal)}})))}catch(f){f instanceof I||wt(n,f,{raisedBy:"effect"})}finally{await Promise.all(u),L(p,xt),i.pending.delete(p)}},c=cn(t);return{middleware:i=>d=>T=>{if(!(0,Mt.isAction)(T))return d(T);if(Re.match(T))return a(T.payload);if(qe.match(T)){c();return}if(we.match(T))return s(T.payload);let g=i.getState(),p=()=>{if(g===Et)throw new Error(x(23));return g},h;try{if(h=d(T),t.size>0){let u=i.getState(),f=Array.from(t.values());for(let k of f){let A=!1;try{A=k.predicate(T,u,g)}catch(m){A=!1,wt(n,m,{raisedBy:"predicate"})}A&&y(k,T,i,p)}}}finally{g=Et}return h},startListening:a,stopListening:s,clearListeners:c}};var vt=require("redux");var un=e=>({middleware:e,applied:new Map}),ln=e=>t=>t?.meta?.instanceId===e,Dt=()=>{let e=O(),t=new Map,r=Object.assign(b("dynamicMiddleware/add",(...y)=>({payload:y,meta:{instanceId:e}})),{withTypes:()=>r}),n=Object.assign(function(...c){c.forEach(l=>{v(t,l,un)})},{withTypes:()=>n}),o=y=>{let c=Array.from(t.values()).map(l=>v(l.applied,y,l.middleware));return(0,vt.compose)(...c)},a=B(r,ln(e));return{middleware:y=>c=>l=>a(l)?(n(...l.payload),y.dispatch):o(y)(c)(l),addMiddleware:n,withMiddleware:r,instanceId:e}};var Ot=require("redux");var pn=e=>"reducerPath"in e&&typeof e.reducerPath=="string",fn=e=>e.flatMap(t=>pn(t)?[[t.reducerPath,t.reducer]]:Object.entries(t)),$e=Symbol.for("rtk-state-proxy-original"),yn=e=>!!e&&!!e[$e],hn=new WeakMap,An=(e,t,r)=>v(hn,e,()=>new Proxy(e,{get:(n,o,a)=>{if(o===$e)return n;let s=Reflect.get(n,o,a);if(typeof s>"u"){let y=r[o];if(typeof y<"u")return y;let c=t[o];if(c){let l=c(void 0,{type:O()});if(typeof l>"u")throw new Error(x(24));return r[o]=l,l}}return s}})),Tn=e=>{if(!yn(e))throw new Error(x(25));return e[$e]},mn={},gn=(e=mn)=>e;function Nt(...e){let t=Object.fromEntries(fn(e)),r=()=>Object.keys(t).length?(0,Ot.combineReducers)(t):gn,n=r();function o(c,l){return n(c,l)}o.withLazyLoadedSlices=()=>o;let a={},s=(c,l={})=>{let{reducerPath:i,reducer:d}=c,T=t[i];return!l.overrideExisting&&T&&T!==d?(typeof process<"u",o):(l.overrideExisting&&T!==d&&delete a[i],t[i]=d,n=r(),o)},y=Object.assign(function(l,i){return function(T,...g){return l(An(i?i(T,...g):T,t,a),...g)}},{original:Tn});return Object.assign(o,{inject:s,selector:y})}function x(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}0&&(module.exports={ReducerType,SHOULD_AUTOBATCH,TaskAbortError,Tuple,addListener,asyncThunkCreator,autoBatchEnhancer,buildCreateSlice,clearAllListeners,combineSlices,configureStore,createAction,createActionCreatorInvariantMiddleware,createAsyncThunk,createDraftSafeSelector,createDraftSafeSelectorCreator,createDynamicMiddleware,createEntityAdapter,createImmutableStateInvariantMiddleware,createListenerMiddleware,createNextState,createReducer,createSelector,createSelectorCreator,createSerializableStateInvariantMiddleware,createSlice,current,findNonSerializableValue,formatProdErrorMessage,freeze,isActionCreator,isAllOf,isAnyOf,isAsyncThunkAction,isDraft,isFluxStandardAction,isFulfilled,isImmutableDefault,isPending,isPlain,isRejected,isRejectedWithValue,lruMemoize,miniSerializeError,nanoid,original,prepareAutoBatched,removeListener,unwrapResult,weakMapMemoize,...require("redux")});
|
| 3 |
+
//# sourceMappingURL=redux-toolkit.production.min.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/cjs/redux-toolkit.production.min.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/index.d.mts
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/index.d.ts
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict'
|
| 2 |
+
if (process.env.NODE_ENV === 'production') {
|
| 3 |
+
module.exports = require('./rtk-query.production.min.cjs')
|
| 4 |
+
} else {
|
| 5 |
+
module.exports = require('./rtk-query.development.cjs')
|
| 6 |
+
}
|
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.development.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";var Ce=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var wt=Object.prototype.hasOwnProperty;var Ct=(e,t)=>{for(var p in t)Ce(e,p,{get:t[p],enumerable:!0})},Ft=(e,t,p,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let y of Mt(t))!wt.call(e,y)&&y!==p&&Ce(e,y,{get:()=>t[y],enumerable:!(m=Bt(t,y))||m.enumerable});return e};var vt=e=>Ft(Ce({},"__esModule",{value:!0}),e);var Wt={};Ct(Wt,{NamedSchemaError:()=>oe,QueryStatus:()=>De,_NEVER:()=>ft,buildCreateApi:()=>Me,copyWithStructuralSharing:()=>me,coreModule:()=>we,coreModuleName:()=>Se,createApi:()=>It,defaultSerializeQueryArgs:()=>Re,fakeBaseQuery:()=>mt,fetchBaseQuery:()=>Je,retry:()=>Ye,setupListeners:()=>Xe,skipToken:()=>Ae});module.exports=vt(Wt);var De=(y=>(y.uninitialized="uninitialized",y.pending="pending",y.fulfilled="fulfilled",y.rejected="rejected",y))(De||{});function Fe(e){return{status:e,isUninitialized:e==="uninitialized",isLoading:e==="pending",isSuccess:e==="fulfilled",isError:e==="rejected"}}var i=require("@reduxjs/toolkit");var Le=i.isPlainObject;function me(e,t){if(e===t||!(Le(e)&&Le(t)||Array.isArray(e)&&Array.isArray(t)))return t;let p=Object.keys(t),m=Object.keys(e),y=p.length===m.length,D=Array.isArray(t)?[]:{};for(let h of p)D[h]=me(e[h],t[h]),y&&(y=e[h]===D[h]);return y?e:D}function J(e){let t=0;for(let p in e)t++;return t}var ve=e=>[].concat(...e);function je(e){return new RegExp("(^|:)//").test(e)}function He(){return typeof document>"u"?!0:document.visibilityState!=="hidden"}function re(e){return e!=null}function _e(){return typeof navigator>"u"||navigator.onLine===void 0?!0:navigator.onLine}var Ot=e=>e.replace(/\/$/,""),Nt=e=>e.replace(/^\//,"");function Ve(e,t){if(!e)return t;if(!t)return e;if(je(t))return t;let p=e.endsWith("/")||!t.startsWith("?")?"/":"";return e=Ot(e),t=Nt(t),`${e}${p}${t}`}function ze(e,t,p){return e.has(t)?e.get(t):e.set(t,p).get(t)}var We=(...e)=>fetch(...e),qt=e=>e.status>=200&&e.status<=299,Kt=e=>/ion\/(vnd\.api\+)?json/.test(e.get("content-type")||"");function $e(e){if(!(0,i.isPlainObject)(e))return e;let t={...e};for(let[p,m]of Object.entries(t))m===void 0&&delete t[p];return t}function Je({baseUrl:e,prepareHeaders:t=A=>A,fetchFn:p=We,paramsSerializer:m,isJsonContentType:y=Kt,jsonContentType:D="application/json",jsonReplacer:h,timeout:B,responseHandler:C,validateStatus:R,...I}={}){return typeof fetch>"u"&&p===We&&console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments."),async(S,o,g)=>{let{getState:M,extra:c,endpoint:s,forced:x,type:l}=o,d,{url:Q,headers:b=new Headers(I.headers),params:E=void 0,responseHandler:k=C??"json",validateStatus:T=R??qt,timeout:u=B,...n}=typeof S=="string"?{url:S}:S,r,a=o.signal;u&&(r=new AbortController,o.signal.addEventListener("abort",r.abort),a=r.signal);let f={...I,signal:a,...n};b=new Headers($e(b)),f.headers=await t(b,{getState:M,arg:S,extra:c,endpoint:s,forced:x,type:l,extraOptions:g})||b;let P=q=>typeof q=="object"&&((0,i.isPlainObject)(q)||Array.isArray(q)||typeof q.toJSON=="function");if(!f.headers.has("content-type")&&P(f.body)&&f.headers.set("content-type",D),P(f.body)&&y(f.headers)&&(f.body=JSON.stringify(f.body,h)),E){let q=~Q.indexOf("?")?"&":"?",v=m?m(E):new URLSearchParams($e(E));Q+=q+v}Q=Ve(e,Q);let O=new Request(Q,f);d={request:new Request(Q,f)};let F,w=!1,U=r&&setTimeout(()=>{w=!0,r.abort()},u);try{F=await p(O)}catch(q){return{error:{status:w?"TIMEOUT_ERROR":"FETCH_ERROR",error:String(q)},meta:d}}finally{U&&clearTimeout(U),r?.signal.removeEventListener("abort",r.abort)}let H=F.clone();d.response=H;let W,j="";try{let q;if(await Promise.all([A(F,k).then(v=>W=v,v=>q=v),H.text().then(v=>j=v,()=>{})]),q)throw q}catch(q){return{error:{status:"PARSING_ERROR",originalStatus:F.status,data:j,error:String(q)},meta:d}}return T(F,W)?{data:W,meta:d}:{error:{status:F.status,data:W},meta:d}};async function A(S,o){if(typeof o=="function")return o(S);if(o==="content-type"&&(o=y(S.headers)?"json":"text"),o==="json"){let g=await S.text();return g.length?JSON.parse(g):null}return S.text()}}var G=class{constructor(t,p=void 0){this.value=t;this.meta=p}};async function Ut(e=0,t=5){let p=Math.min(e,t),m=~~((Math.random()+.4)*(300<<p));await new Promise(y=>setTimeout(D=>y(D),m))}function Lt(e,t){throw Object.assign(new G({error:e,meta:t}),{throwImmediately:!0})}var Ge={},jt=(e,t)=>async(p,m,y)=>{let D=[5,(t||Ge).maxRetries,(y||Ge).maxRetries].filter(I=>I!==void 0),[h]=D.slice(-1),C={maxRetries:h,backoff:Ut,retryCondition:(I,A,{attempt:S})=>S<=h,...t,...y},R=0;for(;;)try{let I=await e(p,m,y);if(I.error)throw new G(I);return I}catch(I){if(R++,I.throwImmediately){if(I instanceof G)return I.value;throw I}if(I instanceof G&&!C.retryCondition(I.value.error,p,{attempt:R,baseQueryApi:m,extraOptions:y}))return I.value;await C.backoff(R,C.maxRetries)}},Ye=Object.assign(jt,{fail:Lt});var ee=(0,i.createAction)("__rtkq/focused"),pe=(0,i.createAction)("__rtkq/unfocused"),te=(0,i.createAction)("__rtkq/online"),ce=(0,i.createAction)("__rtkq/offline"),Oe=!1;function Xe(e,t){function p(){let m=()=>e(ee()),y=()=>e(pe()),D=()=>e(te()),h=()=>e(ce()),B=()=>{window.document.visibilityState==="visible"?m():y()};return Oe||typeof window<"u"&&window.addEventListener&&(window.addEventListener("visibilitychange",B,!1),window.addEventListener("focus",m,!1),window.addEventListener("online",D,!1),window.addEventListener("offline",h,!1),Oe=!0),()=>{window.removeEventListener("focus",m),window.removeEventListener("visibilitychange",B),window.removeEventListener("online",D),window.removeEventListener("offline",h),Oe=!1}}return t?t(e,{onFocus:ee,onFocusLost:pe,onOffline:ce,onOnline:te}):p()}function ie(e){return e.type==="query"}function Ze(e){return e.type==="mutation"}function ae(e){return e.type==="infinitequery"}function le(e){return ie(e)||ae(e)}function ge(e,t,p,m,y,D){return Ht(e)?e(t,p,m,y).filter(re).map(be).map(D):Array.isArray(e)?e.map(be).map(D):[]}function Ht(e){return typeof e=="function"}function be(e){return typeof e=="string"?{type:e}:e}var Pe=require("immer");var An=require("@reduxjs/toolkit");function et(e,t){return e.catch(t)}var fe=Symbol("forceQueryFn"),Qe=e=>typeof e[fe]=="function";function tt({serializeQueryArgs:e,queryThunk:t,infiniteQueryThunk:p,mutationThunk:m,api:y,context:D}){let h=new Map,B=new Map,{unsubscribeQueryResult:C,removeMutationResult:R,updateSubscriptionOptions:I}=y.internalActions;return{buildInitiateQuery:s,buildInitiateInfiniteQuery:x,buildInitiateMutation:l,getRunningQueryThunk:A,getRunningMutationThunk:S,getRunningQueriesThunk:o,getRunningMutationsThunk:g};function A(d,Q){return b=>{let E=D.endpointDefinitions[d],k=e({queryArgs:Q,endpointDefinition:E,endpointName:d});return h.get(b)?.[k]}}function S(d,Q){return b=>B.get(b)?.[Q]}function o(){return d=>Object.values(h.get(d)||{}).filter(re)}function g(){return d=>Object.values(B.get(d)||{}).filter(re)}function M(d){}function c(d,Q){let b=(E,{subscribe:k=!0,forceRefetch:T,subscriptionOptions:u,[fe]:n,...r}={})=>(a,f)=>{let P=e({queryArgs:E,endpointDefinition:Q,endpointName:d}),O,N={...r,type:"query",subscribe:k,forceRefetch:T,subscriptionOptions:u,endpointName:d,originalArgs:E,queryCacheKey:P,[fe]:n};if(ie(Q))O=t(N);else{let{direction:_,initialPageParam:K}=r;O=p({...N,direction:_,initialPageParam:K})}let F=y.endpoints[d].select(E),w=a(O),U=F(f());let{requestId:H,abort:W}=w,j=U.requestId!==H,q=h.get(a)?.[P],v=()=>F(f()),V=Object.assign(n?w.then(v):j&&!q?Promise.resolve(U):Promise.all([q,w]).then(v),{arg:E,requestId:H,subscriptionOptions:u,queryCacheKey:P,abort:W,async unwrap(){let _=await V;if(_.isError)throw _.error;return _.data},refetch:()=>a(b(E,{subscribe:!1,forceRefetch:!0})),unsubscribe(){k&&a(C({queryCacheKey:P,requestId:H}))},updateSubscriptionOptions(_){V.subscriptionOptions=_,a(I({endpointName:d,requestId:H,queryCacheKey:P,options:_}))}});if(!q&&!j&&!n){let _=ze(h,a,{});_[P]=V,V.then(()=>{delete _[P],J(_)||h.delete(a)})}return V};return b}function s(d,Q){return c(d,Q)}function x(d,Q){return c(d,Q)}function l(d){return(Q,{track:b=!0,fixedCacheKey:E}={})=>(k,T)=>{let u=m({type:"mutation",endpointName:d,originalArgs:Q,track:b,fixedCacheKey:E}),n=k(u);let{requestId:r,abort:a,unwrap:f}=n,P=et(n.unwrap().then(w=>({data:w})),w=>({error:w})),O=()=>{k(R({requestId:r,fixedCacheKey:E}))},N=Object.assign(P,{arg:n.arg,requestId:r,abort:a,unwrap:f,reset:O}),F=B.get(k)||{};return B.set(k,F),F[r]=N,N.then(()=>{delete F[r],J(F)||B.delete(k)}),E&&(F[E]=N,N.then(()=>{F[E]===N&&(delete F[E],J(F)||B.delete(k))})),N}}}var nt=require("@standard-schema/utils"),oe=class extends nt.SchemaError{constructor(p,m,y,D){super(p);this.value=m;this.schemaName=y;this._bqMeta=D}};async function ne(e,t,p,m){let y=await e["~standard"].validate(t);if(y.issues)throw new oe(y.issues,t,p,m);return y.value}function _t(e){return e}var Te=(e={})=>({...e,[i.SHOULD_AUTOBATCH]:!0});function rt({reducerPath:e,baseQuery:t,context:{endpointDefinitions:p},serializeQueryArgs:m,api:y,assertTagType:D,selectors:h,onSchemaFailure:B,catchSchemaFailure:C,skipSchemaValidation:R}){let I=(n,r,a,f)=>(P,O)=>{let N=p[n],F=m({queryArgs:r,endpointDefinition:N,endpointName:n});if(P(y.internalActions.queryResultPatched({queryCacheKey:F,patches:a})),!f)return;let w=y.endpoints[n].select(r)(O()),U=ge(N.providesTags,w.data,void 0,r,{},D);P(y.internalActions.updateProvidedBy([{queryCacheKey:F,providedTags:U}]))};function A(n,r,a=0){let f=[r,...n];return a&&f.length>a?f.slice(0,-1):f}function S(n,r,a=0){let f=[...n,r];return a&&f.length>a?f.slice(1):f}let o=(n,r,a,f=!0)=>(P,O)=>{let F=y.endpoints[n].select(r)(O()),w={patches:[],inversePatches:[],undo:()=>P(y.util.patchQueryData(n,r,w.inversePatches,f))};if(F.status==="uninitialized")return w;let U;if("data"in F)if((0,Pe.isDraftable)(F.data)){let[H,W,j]=(0,Pe.produceWithPatches)(F.data,a);w.patches.push(...W),w.inversePatches.push(...j),U=H}else U=a(F.data),w.patches.push({op:"replace",path:[],value:U}),w.inversePatches.push({op:"replace",path:[],value:F.data});return w.patches.length===0||P(y.util.patchQueryData(n,r,w.patches,f)),w},g=(n,r,a)=>f=>f(y.endpoints[n].initiate(r,{subscribe:!1,forceRefetch:!0,[fe]:()=>({data:a})})),M=(n,r)=>n.query&&n[r]?n[r]:_t,c=async(n,{signal:r,abort:a,rejectWithValue:f,fulfillWithValue:P,dispatch:O,getState:N,extra:F})=>{let w=p[n.endpointName],{metaSchema:U,skipSchemaValidation:H=R}=w;try{let W=M(w,"transformResponse"),j={signal:r,abort:a,dispatch:O,getState:N,extra:F,endpoint:n.endpointName,type:n.type,forced:n.type==="query"?s(n,N()):void 0,queryCacheKey:n.type==="query"?n.queryCacheKey:void 0},q=n.type==="query"?n[fe]:void 0,v,V=async(K,L,z,ue)=>{if(L==null&&K.pages.length)return Promise.resolve({data:K});let X={queryArg:n.originalArgs,pageParam:L},ye=await _(X),$=ue?A:S;return{data:{pages:$(K.pages,ye.data,z),pageParams:$(K.pageParams,L,z)},meta:ye.meta}};async function _(K){let L,{extraOptions:z,argSchema:ue,rawResponseSchema:X,responseSchema:ye}=w;if(ue&&!H&&(K=await ne(ue,K,"argSchema",{})),q?L=q():w.query?L=await t(w.query(K),j,z):L=await w.queryFn(K,j,z,de=>t(de,j,z)),typeof process<"u",L.error)throw new G(L.error,L.meta);let{data:$}=L;X&&!H&&($=await ne(X,L.data,"rawResponseSchema",L.meta));let Z=await W($,L.meta,K);return ye&&!H&&(Z=await ne(ye,Z,"responseSchema",L.meta)),{...L,data:Z}}if(n.type==="query"&&"infiniteQueryOptions"in w){let{infiniteQueryOptions:K}=w,{maxPages:L=1/0}=K,z,ue={pages:[],pageParams:[]},X=h.selectQueryEntry(N(),n.queryCacheKey)?.data,$=s(n,N())&&!n.direction||!X?ue:X;if("direction"in n&&n.direction&&$.pages.length){let Z=n.direction==="backward",xe=(Z?Ne:Ee)(K,$,n.originalArgs);z=await V($,xe,L,Z)}else{let{initialPageParam:Z=K.initialPageParam}=n,de=X?.pageParams??[],xe=de[0]??Z,Ke=de.length;z=await V($,xe,L),q&&(z={data:z.data.pages[0]});for(let Ue=1;Ue<Ke;Ue++){let kt=Ee(K,z.data,n.originalArgs);z=await V(z.data,kt,L)}}v=z}else v=await _(n.originalArgs);return U&&!H&&v.meta&&(v.meta=await ne(U,v.meta,"metaSchema",v.meta)),P(v.data,Te({fulfilledTimeStamp:Date.now(),baseQueryMeta:v.meta}))}catch(W){let j=W;if(j instanceof G){let q=M(w,"transformErrorResponse"),{rawErrorResponseSchema:v,errorResponseSchema:V}=w,{value:_,meta:K}=j;try{v&&!H&&(_=await ne(v,_,"rawErrorResponseSchema",K)),U&&!H&&(K=await ne(U,K,"metaSchema",K));let L=await q(_,K,n.originalArgs);return V&&!H&&(L=await ne(V,L,"errorResponseSchema",K)),f(L,Te({baseQueryMeta:K}))}catch(L){j=L}}try{if(j instanceof oe){let q={endpoint:n.endpointName,arg:n.originalArgs,type:n.type,queryCacheKey:n.type==="query"?n.queryCacheKey:void 0};w.onSchemaFailure?.(j,q),B?.(j,q);let{catchSchemaFailure:v=C}=w;if(v)return f(v(j,q),Te({baseQueryMeta:j._bqMeta}))}}catch(q){j=q}throw typeof process<"u",console.error(j),j}};function s(n,r){let a=h.selectQueryEntry(r,n.queryCacheKey),f=h.selectConfig(r).refetchOnMountOrArgChange,P=a?.fulfilledTimeStamp,O=n.forceRefetch??(n.subscribe&&f);return O?O===!0||(Number(new Date)-Number(P))/1e3>=O:!1}let x=()=>(0,i.createAsyncThunk)(`${e}/executeQuery`,c,{getPendingMeta({arg:r}){let a=p[r.endpointName];return Te({startedTimeStamp:Date.now(),...ae(a)?{direction:r.direction}:{}})},condition(r,{getState:a}){let f=a(),P=h.selectQueryEntry(f,r.queryCacheKey),O=P?.fulfilledTimeStamp,N=r.originalArgs,F=P?.originalArgs,w=p[r.endpointName],U=r.direction;return Qe(r)?!0:P?.status==="pending"?!1:s(r,f)||ie(w)&&w?.forceRefetch?.({currentArg:N,previousArg:F,endpointState:P,state:f})?!0:!(O&&!U)},dispatchConditionRejection:!0}),l=x(),d=x(),Q=(0,i.createAsyncThunk)(`${e}/executeMutation`,c,{getPendingMeta(){return Te({startedTimeStamp:Date.now()})}}),b=n=>"force"in n,E=n=>"ifOlderThan"in n,k=(n,r,a)=>(f,P)=>{let O=b(a)&&a.force,N=E(a)&&a.ifOlderThan,F=(U=!0)=>{let H={forceRefetch:U,isPrefetch:!0};return y.endpoints[n].initiate(r,H)},w=y.endpoints[n].select(r)(P());if(O)f(F());else if(N){let U=w?.fulfilledTimeStamp;if(!U){f(F());return}(Number(new Date)-Number(new Date(U)))/1e3>=N&&f(F())}else f(F(!1))};function T(n){return r=>r?.meta?.arg?.endpointName===n}function u(n,r){return{matchPending:(0,i.isAllOf)((0,i.isPending)(n),T(r)),matchFulfilled:(0,i.isAllOf)((0,i.isFulfilled)(n),T(r)),matchRejected:(0,i.isAllOf)((0,i.isRejected)(n),T(r))}}return{queryThunk:l,mutationThunk:Q,infiniteQueryThunk:d,prefetch:k,updateQueryData:o,upsertQueryData:g,patchQueryData:I,buildMatchThunkActions:u}}function Ee(e,{pages:t,pageParams:p},m){let y=t.length-1;return e.getNextPageParam(t[y],t,p[y],p,m)}function Ne(e,{pages:t,pageParams:p},m){return e.getPreviousPageParam?.(t[0],t,p[0],p,m)}function Ie(e,t,p,m){return ge(p[e.meta.arg.endpointName][t],(0,i.isFulfilled)(e)?e.payload:void 0,(0,i.isRejectedWithValue)(e)?e.payload:void 0,e.meta.arg.originalArgs,"baseQueryMeta"in e.meta?e.meta.baseQueryMeta:void 0,m)}var at=require("immer"),he=require("immer");function ke(e,t,p){let m=e[t];m&&p(m)}function se(e){return("arg"in e?e.arg.fixedCacheKey:e.fixedCacheKey)??e.requestId}function it(e,t,p){let m=e[se(t)];m&&p(m)}var Be={};function ot({reducerPath:e,queryThunk:t,mutationThunk:p,serializeQueryArgs:m,context:{endpointDefinitions:y,apiUid:D,extractRehydrationInfo:h,hasRehydrationInfo:B},assertTagType:C,config:R}){let I=(0,i.createAction)(`${e}/resetApiState`);function A(T,u,n,r){T[u.queryCacheKey]??={status:"uninitialized",endpointName:u.endpointName},ke(T,u.queryCacheKey,a=>{a.status="pending",a.requestId=n&&a.requestId?a.requestId:r.requestId,u.originalArgs!==void 0&&(a.originalArgs=u.originalArgs),a.startedTimeStamp=r.startedTimeStamp;let f=y[r.arg.endpointName];ae(f)&&"direction"in u&&(a.direction=u.direction)})}function S(T,u,n,r){ke(T,u.arg.queryCacheKey,a=>{if(a.requestId!==u.requestId&&!r)return;let{merge:f}=y[u.arg.endpointName];if(a.status="fulfilled",f)if(a.data!==void 0){let{fulfilledTimeStamp:P,arg:O,baseQueryMeta:N,requestId:F}=u,w=(0,i.createNextState)(a.data,U=>f(U,n,{arg:O.originalArgs,baseQueryMeta:N,fulfilledTimeStamp:P,requestId:F}));a.data=w}else a.data=n;else a.data=y[u.arg.endpointName].structuralSharing??!0?me((0,at.isDraft)(a.data)?(0,he.original)(a.data):a.data,n):n;delete a.error,a.fulfilledTimeStamp=u.fulfilledTimeStamp})}let o=(0,i.createSlice)({name:`${e}/queries`,initialState:Be,reducers:{removeQueryResult:{reducer(T,{payload:{queryCacheKey:u}}){delete T[u]},prepare:(0,i.prepareAutoBatched)()},cacheEntriesUpserted:{reducer(T,u){for(let n of u.payload){let{queryDescription:r,value:a}=n;A(T,r,!0,{arg:r,requestId:u.meta.requestId,startedTimeStamp:u.meta.timestamp}),S(T,{arg:r,requestId:u.meta.requestId,fulfilledTimeStamp:u.meta.timestamp,baseQueryMeta:{}},a,!0)}},prepare:T=>({payload:T.map(r=>{let{endpointName:a,arg:f,value:P}=r,O=y[a];return{queryDescription:{type:"query",endpointName:a,originalArgs:r.arg,queryCacheKey:m({queryArgs:f,endpointDefinition:O,endpointName:a})},value:P}}),meta:{[i.SHOULD_AUTOBATCH]:!0,requestId:(0,i.nanoid)(),timestamp:Date.now()}})},queryResultPatched:{reducer(T,{payload:{queryCacheKey:u,patches:n}}){ke(T,u,r=>{r.data=(0,he.applyPatches)(r.data,n.concat())})},prepare:(0,i.prepareAutoBatched)()}},extraReducers(T){T.addCase(t.pending,(u,{meta:n,meta:{arg:r}})=>{let a=Qe(r);A(u,r,a,n)}).addCase(t.fulfilled,(u,{meta:n,payload:r})=>{let a=Qe(n.arg);S(u,n,r,a)}).addCase(t.rejected,(u,{meta:{condition:n,arg:r,requestId:a},error:f,payload:P})=>{ke(u,r.queryCacheKey,O=>{if(!n){if(O.requestId!==a)return;O.status="rejected",O.error=P??f}})}).addMatcher(B,(u,n)=>{let{queries:r}=h(n);for(let[a,f]of Object.entries(r))(f?.status==="fulfilled"||f?.status==="rejected")&&(u[a]=f)})}}),g=(0,i.createSlice)({name:`${e}/mutations`,initialState:Be,reducers:{removeMutationResult:{reducer(T,{payload:u}){let n=se(u);n in T&&delete T[n]},prepare:(0,i.prepareAutoBatched)()}},extraReducers(T){T.addCase(p.pending,(u,{meta:n,meta:{requestId:r,arg:a,startedTimeStamp:f}})=>{a.track&&(u[se(n)]={requestId:r,status:"pending",endpointName:a.endpointName,startedTimeStamp:f})}).addCase(p.fulfilled,(u,{payload:n,meta:r})=>{r.arg.track&&it(u,r,a=>{a.requestId===r.requestId&&(a.status="fulfilled",a.data=n,a.fulfilledTimeStamp=r.fulfilledTimeStamp)})}).addCase(p.rejected,(u,{payload:n,error:r,meta:a})=>{a.arg.track&&it(u,a,f=>{f.requestId===a.requestId&&(f.status="rejected",f.error=n??r)})}).addMatcher(B,(u,n)=>{let{mutations:r}=h(n);for(let[a,f]of Object.entries(r))(f?.status==="fulfilled"||f?.status==="rejected")&&a!==f?.requestId&&(u[a]=f)})}}),M={tags:{},keys:{}},c=(0,i.createSlice)({name:`${e}/invalidation`,initialState:M,reducers:{updateProvidedBy:{reducer(T,u){for(let{queryCacheKey:n,providedTags:r}of u.payload){s(T,n);for(let{type:a,id:f}of r){let P=(T.tags[a]??={})[f||"__internal_without_id"]??=[];P.includes(n)||P.push(n)}T.keys[n]=r}},prepare:(0,i.prepareAutoBatched)()}},extraReducers(T){T.addCase(o.actions.removeQueryResult,(u,{payload:{queryCacheKey:n}})=>{s(u,n)}).addMatcher(B,(u,n)=>{let{provided:r}=h(n);for(let[a,f]of Object.entries(r))for(let[P,O]of Object.entries(f)){let N=(u.tags[a]??={})[P||"__internal_without_id"]??=[];for(let F of O)N.includes(F)||N.push(F)}}).addMatcher((0,i.isAnyOf)((0,i.isFulfilled)(t),(0,i.isRejectedWithValue)(t)),(u,n)=>{x(u,[n])}).addMatcher(o.actions.cacheEntriesUpserted.match,(u,n)=>{let r=n.payload.map(({queryDescription:a,value:f})=>({type:"UNKNOWN",payload:f,meta:{requestStatus:"fulfilled",requestId:"UNKNOWN",arg:a}}));x(u,r)})}});function s(T,u){let n=T.keys[u]??[];for(let r of n){let a=r.type,f=r.id??"__internal_without_id",P=T.tags[a]?.[f];P&&(T.tags[a][f]=P.filter(O=>O!==u))}delete T.keys[u]}function x(T,u){let n=u.map(r=>{let a=Ie(r,"providesTags",y,C),{queryCacheKey:f}=r.meta.arg;return{queryCacheKey:f,providedTags:a}});c.caseReducers.updateProvidedBy(T,c.actions.updateProvidedBy(n))}let l=(0,i.createSlice)({name:`${e}/subscriptions`,initialState:Be,reducers:{updateSubscriptionOptions(T,u){},unsubscribeQueryResult(T,u){},internal_getRTKQSubscriptions(){}}}),d=(0,i.createSlice)({name:`${e}/internalSubscriptions`,initialState:Be,reducers:{subscriptionsUpdated:{reducer(T,u){return(0,he.applyPatches)(T,u.payload)},prepare:(0,i.prepareAutoBatched)()}}}),Q=(0,i.createSlice)({name:`${e}/config`,initialState:{online:_e(),focused:He(),middlewareRegistered:!1,...R},reducers:{middlewareRegistered(T,{payload:u}){T.middlewareRegistered=T.middlewareRegistered==="conflict"||D!==u?"conflict":!0}},extraReducers:T=>{T.addCase(te,u=>{u.online=!0}).addCase(ce,u=>{u.online=!1}).addCase(ee,u=>{u.focused=!0}).addCase(pe,u=>{u.focused=!1}).addMatcher(B,u=>({...u}))}}),b=(0,i.combineReducers)({queries:o.reducer,mutations:g.reducer,provided:c.reducer,subscriptions:d.reducer,config:Q.reducer}),E=(T,u)=>b(I.match(u)?void 0:T,u),k={...Q.actions,...o.actions,...l.actions,...d.actions,...g.actions,...c.actions,resetApiState:I};return{reducer:E,actions:k}}var Ae=Symbol.for("RTKQ/skipToken"),yt={status:"uninitialized"},st=(0,i.createNextState)(yt,()=>{}),ut=(0,i.createNextState)(yt,()=>{});function dt({serializeQueryArgs:e,reducerPath:t,createSelector:p}){let m=l=>st,y=l=>ut;return{buildQuerySelector:S,buildInfiniteQuerySelector:o,buildMutationSelector:g,selectInvalidatedBy:M,selectCachedArgsForQuery:c,selectApiState:h,selectQueries:B,selectMutations:R,selectQueryEntry:C,selectConfig:I};function D(l){return{...l,...Fe(l.status)}}function h(l){return l[t]}function B(l){return h(l)?.queries}function C(l,d){return B(l)?.[d]}function R(l){return h(l)?.mutations}function I(l){return h(l)?.config}function A(l,d,Q){return b=>{if(b===Ae)return p(m,Q);let E=e({queryArgs:b,endpointDefinition:d,endpointName:l});return p(T=>C(T,E)??st,Q)}}function S(l,d){return A(l,d,D)}function o(l,d){let{infiniteQueryOptions:Q}=d;function b(E){let k={...E,...Fe(E.status)},{isLoading:T,isError:u,direction:n}=k,r=n==="forward",a=n==="backward";return{...k,hasNextPage:s(Q,k.data,k.originalArgs),hasPreviousPage:x(Q,k.data,k.originalArgs),isFetchingNextPage:T&&r,isFetchingPreviousPage:T&&a,isFetchNextPageError:u&&r,isFetchPreviousPageError:u&&a}}return A(l,d,b)}function g(){return l=>{let d;return typeof l=="object"?d=se(l)??Ae:d=l,p(d===Ae?y:E=>h(E)?.mutations?.[d]??ut,D)}}function M(l,d){let Q=l[t],b=new Set;for(let E of d.filter(re).map(be)){let k=Q.provided.tags[E.type];if(!k)continue;let T=(E.id!==void 0?k[E.id]:ve(Object.values(k)))??[];for(let u of T)b.add(u)}return ve(Array.from(b.values()).map(E=>{let k=Q.queries[E];return k?[{queryCacheKey:E,endpointName:k.endpointName,originalArgs:k.originalArgs}]:[]}))}function c(l,d){return Object.values(B(l)).filter(Q=>Q?.endpointName===d&&Q.status!=="uninitialized").map(Q=>Q.originalArgs)}function s(l,d,Q){return d?Ee(l,d,Q)!=null:!1}function x(l,d,Q){return!d||!l.getPreviousPageParam?!1:Ne(l,d,Q)!=null}}var ct=require("@reduxjs/toolkit");var pt=WeakMap?new WeakMap:void 0,Re=({endpointName:e,queryArgs:t})=>{let p="",m=pt?.get(t);if(typeof m=="string")p=m;else{let y=JSON.stringify(t,(D,h)=>(h=typeof h=="bigint"?{$bigint:h.toString()}:h,h=(0,i.isPlainObject)(h)?Object.keys(h).sort().reduce((B,C)=>(B[C]=h[C],B),{}):h,h));(0,i.isPlainObject)(t)&&pt?.set(t,y),p=y}return`${e}(${p})`};var qe=require("reselect");function Me(...e){return function(p){let m=(0,qe.weakMapMemoize)(R=>p.extractRehydrationInfo?.(R,{reducerPath:p.reducerPath??"api"})),y={reducerPath:"api",keepUnusedDataFor:60,refetchOnMountOrArgChange:!1,refetchOnFocus:!1,refetchOnReconnect:!1,invalidationBehavior:"delayed",...p,extractRehydrationInfo:m,serializeQueryArgs(R){let I=Re;if("serializeQueryArgs"in R.endpointDefinition){let A=R.endpointDefinition.serializeQueryArgs;I=S=>{let o=A(S);return typeof o=="string"?o:Re({...S,queryArgs:o})}}else p.serializeQueryArgs&&(I=p.serializeQueryArgs);return I(R)},tagTypes:[...p.tagTypes||[]]},D={endpointDefinitions:{},batch(R){R()},apiUid:(0,i.nanoid)(),extractRehydrationInfo:m,hasRehydrationInfo:(0,qe.weakMapMemoize)(R=>m(R)!=null)},h={injectEndpoints:C,enhanceEndpoints({addTagTypes:R,endpoints:I}){if(R)for(let A of R)y.tagTypes.includes(A)||y.tagTypes.push(A);if(I)for(let[A,S]of Object.entries(I))typeof S=="function"?S(D.endpointDefinitions[A]):Object.assign(D.endpointDefinitions[A]||{},S);return h}},B=e.map(R=>R.init(h,y,D));function C(R){let I=R.endpoints({query:A=>({...A,type:"query"}),mutation:A=>({...A,type:"mutation"}),infiniteQuery:A=>({...A,type:"infinitequery"})});for(let[A,S]of Object.entries(I)){if(R.overrideExisting!==!0&&A in D.endpointDefinitions){if(R.overrideExisting==="throw")throw new Error((0,ct.formatProdErrorMessage)(39));typeof process<"u";continue}typeof process<"u",D.endpointDefinitions[A]=S;for(let o of B)o.injectEndpoint(A,S)}return h}return h.injectEndpoints({endpoints:p.endpoints})}}var lt=require("@reduxjs/toolkit"),ft=Symbol();function mt(){return function(){throw new Error((0,lt.formatProdErrorMessage)(33))}}var Pt=require("immer");function Y(e,...t){return Object.assign(e,...t)}var gt=require("immer");var Qt=({api:e,queryThunk:t,internalState:p})=>{let m=`${e.reducerPath}/subscriptions`,y=null,D=null,{updateSubscriptionOptions:h,unsubscribeQueryResult:B}=e.internalActions,C=(o,g)=>{if(h.match(g)){let{queryCacheKey:c,requestId:s,options:x}=g.payload;return o?.[c]?.[s]&&(o[c][s]=x),!0}if(B.match(g)){let{queryCacheKey:c,requestId:s}=g.payload;return o[c]&&delete o[c][s],!0}if(e.internalActions.removeQueryResult.match(g))return delete o[g.payload.queryCacheKey],!0;if(t.pending.match(g)){let{meta:{arg:c,requestId:s}}=g,x=o[c.queryCacheKey]??={};return x[`${s}_running`]={},c.subscribe&&(x[s]=c.subscriptionOptions??x[s]??{}),!0}let M=!1;if(t.fulfilled.match(g)||t.rejected.match(g)){let c=o[g.meta.arg.queryCacheKey]||{},s=`${g.meta.requestId}_running`;M||=!!c[s],delete c[s]}if(t.rejected.match(g)){let{meta:{condition:c,arg:s,requestId:x}}=g;if(c&&s.subscribe){let l=o[s.queryCacheKey]??={};l[x]=s.subscriptionOptions??l[x]??{},M=!0}}return M},R=()=>p.currentSubscriptions,S={getSubscriptions:R,getSubscriptionCount:o=>{let M=R()[o]??{};return J(M)},isRequestSubscribed:(o,g)=>!!R()?.[o]?.[g]};return(o,g)=>{if(y||(y=JSON.parse(JSON.stringify(p.currentSubscriptions))),e.util.resetApiState.match(o))return y=p.currentSubscriptions={},D=null,[!0,!1];if(e.internalActions.internal_getRTKQSubscriptions.match(o))return[!1,S];let M=C(p.currentSubscriptions,o),c=!0;if(M){D||(D=setTimeout(()=>{let l=JSON.parse(JSON.stringify(p.currentSubscriptions)),[,d]=(0,gt.produceWithPatches)(y,()=>l);g.next(e.internalActions.subscriptionsUpdated(d)),y=l,D=null},500));let s=typeof o.type=="string"&&!!o.type.startsWith(m),x=t.rejected.match(o)&&o.meta.condition&&!!o.meta.arg.subscribe;c=!s&&!x}return[c,!1]}};function Vt(e){for(let t in e)return!1;return!0}var zt=2147483647/1e3-1,Tt=({reducerPath:e,api:t,queryThunk:p,context:m,internalState:y,selectors:{selectQueryEntry:D,selectConfig:h}})=>{let{removeQueryResult:B,unsubscribeQueryResult:C,cacheEntriesUpserted:R}=t.internalActions,I=(0,i.isAnyOf)(C.match,p.fulfilled,p.rejected,R.match);function A(c){let s=y.currentSubscriptions[c];return!!s&&!Vt(s)}let S={},o=(c,s,x)=>{let l=s.getState(),d=h(l);if(I(c)){let Q;if(R.match(c))Q=c.payload.map(b=>b.queryDescription.queryCacheKey);else{let{queryCacheKey:b}=C.match(c)?c.payload:c.meta.arg;Q=[b]}g(Q,s,d)}if(t.util.resetApiState.match(c))for(let[Q,b]of Object.entries(S))b&&clearTimeout(b),delete S[Q];if(m.hasRehydrationInfo(c)){let{queries:Q}=m.extractRehydrationInfo(c);g(Object.keys(Q),s,d)}};function g(c,s,x){let l=s.getState();for(let d of c){let Q=D(l,d);M(d,Q?.endpointName,s,x)}}function M(c,s,x,l){let Q=m.endpointDefinitions[s]?.keepUnusedDataFor??l.keepUnusedDataFor;if(Q===1/0)return;let b=Math.max(0,Math.min(Q,zt));if(!A(c)){let E=S[c];E&&clearTimeout(E),S[c]=setTimeout(()=>{A(c)||x.dispatch(B({queryCacheKey:c})),delete S[c]},b*1e3)}}return o};var ht=new Error("Promise never resolved before cacheEntryRemoved."),At=({api:e,reducerPath:t,context:p,queryThunk:m,mutationThunk:y,internalState:D,selectors:{selectQueryEntry:h,selectApiState:B}})=>{let C=(0,i.isAsyncThunkAction)(m),R=(0,i.isAsyncThunkAction)(y),I=(0,i.isFulfilled)(m,y),A={};function S(s,x,l){let d=A[s];d?.valueResolved&&(d.valueResolved({data:x,meta:l}),delete d.valueResolved)}function o(s){let x=A[s];x&&(delete A[s],x.cacheEntryRemoved())}let g=(s,x,l)=>{let d=M(s);function Q(b,E,k,T){let u=h(l,E),n=h(x.getState(),E);!u&&n&&c(b,T,E,x,k)}if(m.pending.match(s))Q(s.meta.arg.endpointName,d,s.meta.requestId,s.meta.arg.originalArgs);else if(e.internalActions.cacheEntriesUpserted.match(s))for(let{queryDescription:b,value:E}of s.payload){let{endpointName:k,originalArgs:T,queryCacheKey:u}=b;Q(k,u,s.meta.requestId,T),S(u,E,{})}else if(y.pending.match(s))x.getState()[t].mutations[d]&&c(s.meta.arg.endpointName,s.meta.arg.originalArgs,d,x,s.meta.requestId);else if(I(s))S(d,s.payload,s.meta.baseQueryMeta);else if(e.internalActions.removeQueryResult.match(s)||e.internalActions.removeMutationResult.match(s))o(d);else if(e.util.resetApiState.match(s))for(let b of Object.keys(A))o(b)};function M(s){return C(s)?s.meta.arg.queryCacheKey:R(s)?s.meta.arg.fixedCacheKey??s.meta.requestId:e.internalActions.removeQueryResult.match(s)?s.payload.queryCacheKey:e.internalActions.removeMutationResult.match(s)?se(s.payload):""}function c(s,x,l,d,Q){let b=p.endpointDefinitions[s],E=b?.onCacheEntryAdded;if(!E)return;let k={},T=new Promise(P=>{k.cacheEntryRemoved=P}),u=Promise.race([new Promise(P=>{k.valueResolved=P}),T.then(()=>{throw ht})]);u.catch(()=>{}),A[l]=k;let n=e.endpoints[s].select(le(b)?x:l),r=d.dispatch((P,O,N)=>N),a={...d,getCacheEntry:()=>n(d.getState()),requestId:Q,extra:r,updateCachedData:le(b)?P=>d.dispatch(e.util.updateQueryData(s,x,P)):void 0,cacheDataLoaded:u,cacheEntryRemoved:T},f=E(x,a);Promise.resolve(f).catch(P=>{if(P!==ht)throw P})}return g};var Rt=({api:e,context:{apiUid:t},reducerPath:p})=>(m,y)=>{e.util.resetApiState.match(m)&&y.dispatch(e.internalActions.middlewareRegistered(t)),typeof process<"u"};var St=({reducerPath:e,context:t,context:{endpointDefinitions:p},mutationThunk:m,queryThunk:y,api:D,assertTagType:h,refetchQuery:B,internalState:C})=>{let{removeQueryResult:R}=D.internalActions,I=(0,i.isAnyOf)((0,i.isFulfilled)(m),(0,i.isRejectedWithValue)(m)),A=(0,i.isAnyOf)((0,i.isFulfilled)(m,y),(0,i.isRejected)(m,y)),S=[],o=(c,s)=>{I(c)?M(Ie(c,"invalidatesTags",p,h),s):A(c)?M([],s):D.util.invalidateTags.match(c)&&M(ge(c.payload,void 0,void 0,void 0,void 0,h),s)};function g(c){let{queries:s,mutations:x}=c;for(let l of[s,x])for(let d in l)if(l[d]?.status==="pending")return!0;return!1}function M(c,s){let x=s.getState(),l=x[e];if(S.push(...c),l.config.invalidationBehavior==="delayed"&&g(l))return;let d=S;if(S=[],d.length===0)return;let Q=D.util.selectInvalidatedBy(x,d);t.batch(()=>{let b=Array.from(Q.values());for(let{queryCacheKey:E}of b){let k=l.queries[E],T=C.currentSubscriptions[E]??{};k&&(J(T)===0?s.dispatch(R({queryCacheKey:E})):k.status!=="uninitialized"&&s.dispatch(B(k)))}})}return o};var xt=({reducerPath:e,queryThunk:t,api:p,refetchQuery:m,internalState:y})=>{let D={},h=(o,g)=>{(p.internalActions.updateSubscriptionOptions.match(o)||p.internalActions.unsubscribeQueryResult.match(o))&&R(o.payload,g),(t.pending.match(o)||t.rejected.match(o)&&o.meta.condition)&&R(o.meta.arg,g),(t.fulfilled.match(o)||t.rejected.match(o)&&!o.meta.condition)&&C(o.meta.arg,g),p.util.resetApiState.match(o)&&A()};function B(o,g){let c=g.getState()[e].queries[o],s=y.currentSubscriptions[o];if(!(!c||c.status==="uninitialized"))return s}function C({queryCacheKey:o},g){let M=g.getState()[e],c=M.queries[o],s=y.currentSubscriptions[o];if(!c||c.status==="uninitialized")return;let{lowestPollingInterval:x,skipPollingIfUnfocused:l}=S(s);if(!Number.isFinite(x))return;let d=D[o];d?.timeout&&(clearTimeout(d.timeout),d.timeout=void 0);let Q=Date.now()+x;D[o]={nextPollTimestamp:Q,pollingInterval:x,timeout:setTimeout(()=>{(M.config.focused||!l)&&g.dispatch(m(c)),C({queryCacheKey:o},g)},x)}}function R({queryCacheKey:o},g){let c=g.getState()[e].queries[o],s=y.currentSubscriptions[o];if(!c||c.status==="uninitialized")return;let{lowestPollingInterval:x}=S(s);if(!Number.isFinite(x)){I(o);return}let l=D[o],d=Date.now()+x;(!l||d<l.nextPollTimestamp)&&C({queryCacheKey:o},g)}function I(o){let g=D[o];g?.timeout&&clearTimeout(g.timeout),delete D[o]}function A(){for(let o of Object.keys(D))I(o)}function S(o={}){let g=!1,M=Number.POSITIVE_INFINITY;for(let c in o)o[c].pollingInterval&&(M=Math.min(o[c].pollingInterval,M),g=o[c].skipPollingIfUnfocused||g);return{lowestPollingInterval:M,skipPollingIfUnfocused:g}}return h};var Dt=({api:e,context:t,queryThunk:p,mutationThunk:m})=>{let y=(0,i.isPending)(p,m),D=(0,i.isRejected)(p,m),h=(0,i.isFulfilled)(p,m),B={};return(R,I)=>{if(y(R)){let{requestId:A,arg:{endpointName:S,originalArgs:o}}=R.meta,g=t.endpointDefinitions[S],M=g?.onQueryStarted;if(M){let c={},s=new Promise((Q,b)=>{c.resolve=Q,c.reject=b});s.catch(()=>{}),B[A]=c;let x=e.endpoints[S].select(le(g)?o:A),l=I.dispatch((Q,b,E)=>E),d={...I,getCacheEntry:()=>x(I.getState()),requestId:A,extra:l,updateCachedData:le(g)?Q=>I.dispatch(e.util.updateQueryData(S,o,Q)):void 0,queryFulfilled:s};M(o,d)}}else if(h(R)){let{requestId:A,baseQueryMeta:S}=R.meta;B[A]?.resolve({data:R.payload,meta:S}),delete B[A]}else if(D(R)){let{requestId:A,rejectedWithValue:S,baseQueryMeta:o}=R.meta;B[A]?.reject({error:R.payload??R.error,isUnhandledError:!S,meta:o}),delete B[A]}}};var bt=({reducerPath:e,context:t,api:p,refetchQuery:m,internalState:y})=>{let{removeQueryResult:D}=p.internalActions,h=(C,R)=>{ee.match(C)&&B(R,"refetchOnFocus"),te.match(C)&&B(R,"refetchOnReconnect")};function B(C,R){let I=C.getState()[e],A=I.queries,S=y.currentSubscriptions;t.batch(()=>{for(let o of Object.keys(S)){let g=A[o],M=S[o];if(!M||!g)continue;(Object.values(M).some(s=>s[R]===!0)||Object.values(M).every(s=>s[R]===void 0)&&I.config[R])&&(J(M)===0?C.dispatch(D({queryCacheKey:o})):g.status!=="uninitialized"&&C.dispatch(m(g)))}})}return h};function Et(e){let{reducerPath:t,queryThunk:p,api:m,context:y}=e,{apiUid:D}=y,h={invalidateTags:(0,i.createAction)(`${t}/invalidateTags`)},B=A=>A.type.startsWith(`${t}/`),C=[Rt,Tt,St,xt,At,Dt];return{middleware:A=>{let S=!1,g={...e,internalState:{currentSubscriptions:{}},refetchQuery:I,isThisApiSliceAction:B},M=C.map(x=>x(g)),c=Qt(g),s=bt(g);return x=>l=>{if(!(0,i.isAction)(l))return x(l);S||(S=!0,A.dispatch(m.internalActions.middlewareRegistered(D)));let d={...A,next:x},Q=A.getState(),[b,E]=c(l,d,Q),k;if(b?k=x(l):k=E,A.getState()[t]&&(s(l,d,Q),B(l)||y.hasRehydrationInfo(l)))for(let T of M)T(l,d,Q);return k}},actions:h};function I(A){return e.api.endpoints[A.endpointName].initiate(A.originalArgs,{subscribe:!1,forceRefetch:!0})}}var Se=Symbol(),we=({createSelector:e=i.createSelector}={})=>({name:Se,init(t,{baseQuery:p,tagTypes:m,reducerPath:y,serializeQueryArgs:D,keepUnusedDataFor:h,refetchOnMountOrArgChange:B,refetchOnFocus:C,refetchOnReconnect:R,invalidationBehavior:I,onSchemaFailure:A,catchSchemaFailure:S,skipSchemaValidation:o},g){(0,Pt.enablePatches)();let M=v=>(typeof process<"u",v);Object.assign(t,{reducerPath:y,endpoints:{},internalActions:{onOnline:te,onOffline:ce,onFocus:ee,onFocusLost:pe},util:{}});let c=dt({serializeQueryArgs:D,reducerPath:y,createSelector:e}),{selectInvalidatedBy:s,selectCachedArgsForQuery:x,buildQuerySelector:l,buildInfiniteQuerySelector:d,buildMutationSelector:Q}=c;Y(t.util,{selectInvalidatedBy:s,selectCachedArgsForQuery:x});let{queryThunk:b,infiniteQueryThunk:E,mutationThunk:k,patchQueryData:T,updateQueryData:u,upsertQueryData:n,prefetch:r,buildMatchThunkActions:a}=rt({baseQuery:p,reducerPath:y,context:g,api:t,serializeQueryArgs:D,assertTagType:M,selectors:c,onSchemaFailure:A,catchSchemaFailure:S,skipSchemaValidation:o}),{reducer:f,actions:P}=ot({context:g,queryThunk:b,infiniteQueryThunk:E,mutationThunk:k,serializeQueryArgs:D,reducerPath:y,assertTagType:M,config:{refetchOnFocus:C,refetchOnReconnect:R,refetchOnMountOrArgChange:B,keepUnusedDataFor:h,reducerPath:y,invalidationBehavior:I}});Y(t.util,{patchQueryData:T,updateQueryData:u,upsertQueryData:n,prefetch:r,resetApiState:P.resetApiState,upsertQueryEntries:P.cacheEntriesUpserted}),Y(t.internalActions,P);let{middleware:O,actions:N}=Et({reducerPath:y,context:g,queryThunk:b,mutationThunk:k,infiniteQueryThunk:E,api:t,assertTagType:M,selectors:c});Y(t.util,N),Y(t,{reducer:f,middleware:O});let{buildInitiateQuery:F,buildInitiateInfiniteQuery:w,buildInitiateMutation:U,getRunningMutationThunk:H,getRunningMutationsThunk:W,getRunningQueriesThunk:j,getRunningQueryThunk:q}=tt({queryThunk:b,mutationThunk:k,infiniteQueryThunk:E,api:t,serializeQueryArgs:D,context:g});return Y(t.util,{getRunningMutationThunk:H,getRunningMutationsThunk:W,getRunningQueryThunk:q,getRunningQueriesThunk:j}),{name:Se,injectEndpoint(v,V){let _=t,K=_.endpoints[v]??={};ie(V)&&Y(K,{name:v,select:l(v,V),initiate:F(v,V)},a(b,v)),Ze(V)&&Y(K,{name:v,select:Q(),initiate:U(v)},a(k,v)),ae(V)&&Y(K,{name:v,select:d(v,V),initiate:w(v,V)},a(b,v))}}}});var It=Me(we());0&&(module.exports={NamedSchemaError,QueryStatus,_NEVER,buildCreateApi,copyWithStructuralSharing,coreModule,coreModuleName,createApi,defaultSerializeQueryArgs,fakeBaseQuery,fetchBaseQuery,retry,setupListeners,skipToken});
|
| 2 |
+
//# sourceMappingURL=rtk-query.production.min.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/cjs/rtk-query.production.min.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.mts
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/index.d.ts
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict'
|
| 2 |
+
if (process.env.NODE_ENV === 'production') {
|
| 3 |
+
module.exports = require('./rtk-query-react.production.min.cjs')
|
| 4 |
+
} else {
|
| 5 |
+
module.exports = require('./rtk-query-react.development.cjs')
|
| 6 |
+
}
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs
ADDED
|
@@ -0,0 +1,759 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
| 5 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 6 |
+
var __getProtoOf = Object.getPrototypeOf;
|
| 7 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 8 |
+
var __export = (target, all) => {
|
| 9 |
+
for (var name in all)
|
| 10 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 11 |
+
};
|
| 12 |
+
var __copyProps = (to, from, except, desc) => {
|
| 13 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 14 |
+
for (let key of __getOwnPropNames(from))
|
| 15 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 16 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 17 |
+
}
|
| 18 |
+
return to;
|
| 19 |
+
};
|
| 20 |
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
| 21 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
| 22 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
| 23 |
+
// file that has been converted to a CommonJS file using a Babel-
|
| 24 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
| 25 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
| 26 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
| 27 |
+
mod
|
| 28 |
+
));
|
| 29 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 30 |
+
|
| 31 |
+
// src/query/react/index.ts
|
| 32 |
+
var react_exports = {};
|
| 33 |
+
__export(react_exports, {
|
| 34 |
+
ApiProvider: () => ApiProvider,
|
| 35 |
+
UNINITIALIZED_VALUE: () => UNINITIALIZED_VALUE,
|
| 36 |
+
createApi: () => createApi,
|
| 37 |
+
reactHooksModule: () => reactHooksModule,
|
| 38 |
+
reactHooksModuleName: () => reactHooksModuleName
|
| 39 |
+
});
|
| 40 |
+
module.exports = __toCommonJS(react_exports);
|
| 41 |
+
var import_query3 = require("@reduxjs/toolkit/query");
|
| 42 |
+
|
| 43 |
+
// src/query/react/module.ts
|
| 44 |
+
var import_toolkit2 = require("@reduxjs/toolkit");
|
| 45 |
+
var import_react_redux3 = require("react-redux");
|
| 46 |
+
var import_reselect = require("reselect");
|
| 47 |
+
|
| 48 |
+
// src/query/utils/capitalize.ts
|
| 49 |
+
function capitalize(str) {
|
| 50 |
+
return str.replace(str[0], str[0].toUpperCase());
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// src/query/utils/countObjectKeys.ts
|
| 54 |
+
function countObjectKeys(obj) {
|
| 55 |
+
let count = 0;
|
| 56 |
+
for (const _key in obj) {
|
| 57 |
+
count++;
|
| 58 |
+
}
|
| 59 |
+
return count;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// src/query/endpointDefinitions.ts
|
| 63 |
+
function isQueryDefinition(e) {
|
| 64 |
+
return e.type === "query" /* query */;
|
| 65 |
+
}
|
| 66 |
+
function isMutationDefinition(e) {
|
| 67 |
+
return e.type === "mutation" /* mutation */;
|
| 68 |
+
}
|
| 69 |
+
function isInfiniteQueryDefinition(e) {
|
| 70 |
+
return e.type === "infinitequery" /* infinitequery */;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// src/query/tsHelpers.ts
|
| 74 |
+
function safeAssign(target, ...args) {
|
| 75 |
+
return Object.assign(target, ...args);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// src/query/react/buildHooks.ts
|
| 79 |
+
var import_toolkit = require("@reduxjs/toolkit");
|
| 80 |
+
var import_query = require("@reduxjs/toolkit/query");
|
| 81 |
+
var import_react3 = require("react");
|
| 82 |
+
var import_react_redux2 = require("react-redux");
|
| 83 |
+
|
| 84 |
+
// src/query/react/constants.ts
|
| 85 |
+
var UNINITIALIZED_VALUE = Symbol();
|
| 86 |
+
|
| 87 |
+
// src/query/react/useSerializedStableValue.ts
|
| 88 |
+
var import_react = require("react");
|
| 89 |
+
function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
|
| 90 |
+
const incoming = (0, import_react.useMemo)(() => ({
|
| 91 |
+
queryArgs,
|
| 92 |
+
serialized: typeof queryArgs == "object" ? serialize({
|
| 93 |
+
queryArgs,
|
| 94 |
+
endpointDefinition,
|
| 95 |
+
endpointName
|
| 96 |
+
}) : queryArgs
|
| 97 |
+
}), [queryArgs, serialize, endpointDefinition, endpointName]);
|
| 98 |
+
const cache = (0, import_react.useRef)(incoming);
|
| 99 |
+
(0, import_react.useEffect)(() => {
|
| 100 |
+
if (cache.current.serialized !== incoming.serialized) {
|
| 101 |
+
cache.current = incoming;
|
| 102 |
+
}
|
| 103 |
+
}, [incoming]);
|
| 104 |
+
return cache.current.serialized === incoming.serialized ? cache.current.queryArgs : queryArgs;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
// src/query/react/useShallowStableValue.ts
|
| 108 |
+
var import_react2 = require("react");
|
| 109 |
+
var import_react_redux = require("react-redux");
|
| 110 |
+
function useShallowStableValue(value) {
|
| 111 |
+
const cache = (0, import_react2.useRef)(value);
|
| 112 |
+
(0, import_react2.useEffect)(() => {
|
| 113 |
+
if (!(0, import_react_redux.shallowEqual)(cache.current, value)) {
|
| 114 |
+
cache.current = value;
|
| 115 |
+
}
|
| 116 |
+
}, [value]);
|
| 117 |
+
return (0, import_react_redux.shallowEqual)(cache.current, value) ? cache.current : value;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// src/query/react/buildHooks.ts
|
| 121 |
+
var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
| 122 |
+
var isDOM = /* @__PURE__ */ canUseDOM();
|
| 123 |
+
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
| 124 |
+
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
| 125 |
+
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? import_react3.useLayoutEffect : import_react3.useEffect;
|
| 126 |
+
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
| 127 |
+
var noPendingQueryStateSelector = (selected) => {
|
| 128 |
+
if (selected.isUninitialized) {
|
| 129 |
+
return {
|
| 130 |
+
...selected,
|
| 131 |
+
isUninitialized: false,
|
| 132 |
+
isFetching: true,
|
| 133 |
+
isLoading: selected.data !== void 0 ? false : true,
|
| 134 |
+
status: import_query.QueryStatus.pending
|
| 135 |
+
};
|
| 136 |
+
}
|
| 137 |
+
return selected;
|
| 138 |
+
};
|
| 139 |
+
function pick(obj, ...keys) {
|
| 140 |
+
const ret = {};
|
| 141 |
+
keys.forEach((key) => {
|
| 142 |
+
ret[key] = obj[key];
|
| 143 |
+
});
|
| 144 |
+
return ret;
|
| 145 |
+
}
|
| 146 |
+
var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
|
| 147 |
+
function buildHooks({
|
| 148 |
+
api,
|
| 149 |
+
moduleOptions: {
|
| 150 |
+
batch,
|
| 151 |
+
hooks: {
|
| 152 |
+
useDispatch,
|
| 153 |
+
useSelector,
|
| 154 |
+
useStore
|
| 155 |
+
},
|
| 156 |
+
unstable__sideEffectsInRender,
|
| 157 |
+
createSelector
|
| 158 |
+
},
|
| 159 |
+
serializeQueryArgs,
|
| 160 |
+
context
|
| 161 |
+
}) {
|
| 162 |
+
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : import_react3.useEffect;
|
| 163 |
+
return {
|
| 164 |
+
buildQueryHooks,
|
| 165 |
+
buildInfiniteQueryHooks,
|
| 166 |
+
buildMutationHook,
|
| 167 |
+
usePrefetch
|
| 168 |
+
};
|
| 169 |
+
function queryStatePreSelector(currentState, lastResult, queryArgs) {
|
| 170 |
+
if (lastResult?.endpointName && currentState.isUninitialized) {
|
| 171 |
+
const {
|
| 172 |
+
endpointName
|
| 173 |
+
} = lastResult;
|
| 174 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 175 |
+
if (queryArgs !== import_query.skipToken && serializeQueryArgs({
|
| 176 |
+
queryArgs: lastResult.originalArgs,
|
| 177 |
+
endpointDefinition,
|
| 178 |
+
endpointName
|
| 179 |
+
}) === serializeQueryArgs({
|
| 180 |
+
queryArgs,
|
| 181 |
+
endpointDefinition,
|
| 182 |
+
endpointName
|
| 183 |
+
})) lastResult = void 0;
|
| 184 |
+
}
|
| 185 |
+
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
| 186 |
+
if (data === void 0) data = currentState.data;
|
| 187 |
+
const hasData = data !== void 0;
|
| 188 |
+
const isFetching = currentState.isLoading;
|
| 189 |
+
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
| 190 |
+
const isSuccess = currentState.isSuccess || hasData && (isFetching && !lastResult?.isError || currentState.isUninitialized);
|
| 191 |
+
return {
|
| 192 |
+
...currentState,
|
| 193 |
+
data,
|
| 194 |
+
currentData: currentState.data,
|
| 195 |
+
isFetching,
|
| 196 |
+
isLoading,
|
| 197 |
+
isSuccess
|
| 198 |
+
};
|
| 199 |
+
}
|
| 200 |
+
function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
|
| 201 |
+
if (lastResult?.endpointName && currentState.isUninitialized) {
|
| 202 |
+
const {
|
| 203 |
+
endpointName
|
| 204 |
+
} = lastResult;
|
| 205 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 206 |
+
if (queryArgs !== import_query.skipToken && serializeQueryArgs({
|
| 207 |
+
queryArgs: lastResult.originalArgs,
|
| 208 |
+
endpointDefinition,
|
| 209 |
+
endpointName
|
| 210 |
+
}) === serializeQueryArgs({
|
| 211 |
+
queryArgs,
|
| 212 |
+
endpointDefinition,
|
| 213 |
+
endpointName
|
| 214 |
+
})) lastResult = void 0;
|
| 215 |
+
}
|
| 216 |
+
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
| 217 |
+
if (data === void 0) data = currentState.data;
|
| 218 |
+
const hasData = data !== void 0;
|
| 219 |
+
const isFetching = currentState.isLoading;
|
| 220 |
+
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
| 221 |
+
const isSuccess = currentState.isSuccess || isFetching && hasData;
|
| 222 |
+
return {
|
| 223 |
+
...currentState,
|
| 224 |
+
data,
|
| 225 |
+
currentData: currentState.data,
|
| 226 |
+
isFetching,
|
| 227 |
+
isLoading,
|
| 228 |
+
isSuccess
|
| 229 |
+
};
|
| 230 |
+
}
|
| 231 |
+
function usePrefetch(endpointName, defaultOptions) {
|
| 232 |
+
const dispatch = useDispatch();
|
| 233 |
+
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
| 234 |
+
return (0, import_react3.useCallback)((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
|
| 235 |
+
...stableDefaultOptions,
|
| 236 |
+
...options
|
| 237 |
+
})), [endpointName, dispatch, stableDefaultOptions]);
|
| 238 |
+
}
|
| 239 |
+
function useQuerySubscriptionCommonImpl(endpointName, arg, {
|
| 240 |
+
refetchOnReconnect,
|
| 241 |
+
refetchOnFocus,
|
| 242 |
+
refetchOnMountOrArgChange,
|
| 243 |
+
skip = false,
|
| 244 |
+
pollingInterval = 0,
|
| 245 |
+
skipPollingIfUnfocused = false,
|
| 246 |
+
...rest
|
| 247 |
+
} = {}) {
|
| 248 |
+
const {
|
| 249 |
+
initiate
|
| 250 |
+
} = api.endpoints[endpointName];
|
| 251 |
+
const dispatch = useDispatch();
|
| 252 |
+
const subscriptionSelectorsRef = (0, import_react3.useRef)(void 0);
|
| 253 |
+
if (!subscriptionSelectorsRef.current) {
|
| 254 |
+
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
| 255 |
+
if (true) {
|
| 256 |
+
if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
|
| 257 |
+
throw new Error(false ? _formatProdErrorMessage(37) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
|
| 258 |
+
You must add the middleware for RTK-Query to function correctly!`);
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
subscriptionSelectorsRef.current = returnedValue;
|
| 262 |
+
}
|
| 263 |
+
const stableArg = useStableQueryArgs(
|
| 264 |
+
skip ? import_query.skipToken : arg,
|
| 265 |
+
// Even if the user provided a per-endpoint `serializeQueryArgs` with
|
| 266 |
+
// a consistent return value, _here_ we want to use the default behavior
|
| 267 |
+
// so we can tell if _anything_ actually changed. Otherwise, we can end up
|
| 268 |
+
// with a case where the query args did change but the serialization doesn't,
|
| 269 |
+
// and then we never try to initiate a refetch.
|
| 270 |
+
import_query.defaultSerializeQueryArgs,
|
| 271 |
+
context.endpointDefinitions[endpointName],
|
| 272 |
+
endpointName
|
| 273 |
+
);
|
| 274 |
+
const stableSubscriptionOptions = useShallowStableValue({
|
| 275 |
+
refetchOnReconnect,
|
| 276 |
+
refetchOnFocus,
|
| 277 |
+
pollingInterval,
|
| 278 |
+
skipPollingIfUnfocused
|
| 279 |
+
});
|
| 280 |
+
const initialPageParam = rest.initialPageParam;
|
| 281 |
+
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
| 282 |
+
const promiseRef = (0, import_react3.useRef)(void 0);
|
| 283 |
+
let {
|
| 284 |
+
queryCacheKey,
|
| 285 |
+
requestId
|
| 286 |
+
} = promiseRef.current || {};
|
| 287 |
+
let currentRenderHasSubscription = false;
|
| 288 |
+
if (queryCacheKey && requestId) {
|
| 289 |
+
currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
|
| 290 |
+
}
|
| 291 |
+
const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
|
| 292 |
+
usePossiblyImmediateEffect(() => {
|
| 293 |
+
if (subscriptionRemoved) {
|
| 294 |
+
promiseRef.current = void 0;
|
| 295 |
+
}
|
| 296 |
+
}, [subscriptionRemoved]);
|
| 297 |
+
usePossiblyImmediateEffect(() => {
|
| 298 |
+
const lastPromise = promiseRef.current;
|
| 299 |
+
if (typeof process !== "undefined" && false) {
|
| 300 |
+
console.log(subscriptionRemoved);
|
| 301 |
+
}
|
| 302 |
+
if (stableArg === import_query.skipToken) {
|
| 303 |
+
lastPromise?.unsubscribe();
|
| 304 |
+
promiseRef.current = void 0;
|
| 305 |
+
return;
|
| 306 |
+
}
|
| 307 |
+
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
| 308 |
+
if (!lastPromise || lastPromise.arg !== stableArg) {
|
| 309 |
+
lastPromise?.unsubscribe();
|
| 310 |
+
const promise = dispatch(initiate(stableArg, {
|
| 311 |
+
subscriptionOptions: stableSubscriptionOptions,
|
| 312 |
+
forceRefetch: refetchOnMountOrArgChange,
|
| 313 |
+
...isInfiniteQueryDefinition(context.endpointDefinitions[endpointName]) ? {
|
| 314 |
+
initialPageParam: stableInitialPageParam
|
| 315 |
+
} : {}
|
| 316 |
+
}));
|
| 317 |
+
promiseRef.current = promise;
|
| 318 |
+
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
| 319 |
+
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
|
| 320 |
+
}
|
| 321 |
+
}, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, endpointName]);
|
| 322 |
+
return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
|
| 323 |
+
}
|
| 324 |
+
function buildUseQueryState(endpointName, preSelector) {
|
| 325 |
+
const useQueryState = (arg, {
|
| 326 |
+
skip = false,
|
| 327 |
+
selectFromResult
|
| 328 |
+
} = {}) => {
|
| 329 |
+
const {
|
| 330 |
+
select
|
| 331 |
+
} = api.endpoints[endpointName];
|
| 332 |
+
const stableArg = useStableQueryArgs(skip ? import_query.skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
|
| 333 |
+
const lastValue = (0, import_react3.useRef)(void 0);
|
| 334 |
+
const selectDefaultResult = (0, import_react3.useMemo)(() => (
|
| 335 |
+
// Normally ts-ignores are bad and should be avoided, but we're
|
| 336 |
+
// already casting this selector to be `Selector<any>` anyway,
|
| 337 |
+
// so the inconsistencies don't matter here
|
| 338 |
+
// @ts-ignore
|
| 339 |
+
createSelector([
|
| 340 |
+
// @ts-ignore
|
| 341 |
+
select(stableArg),
|
| 342 |
+
(_, lastResult) => lastResult,
|
| 343 |
+
(_) => stableArg
|
| 344 |
+
], preSelector, {
|
| 345 |
+
memoizeOptions: {
|
| 346 |
+
resultEqualityCheck: import_react_redux2.shallowEqual
|
| 347 |
+
}
|
| 348 |
+
})
|
| 349 |
+
), [select, stableArg]);
|
| 350 |
+
const querySelector = (0, import_react3.useMemo)(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
| 351 |
+
devModeChecks: {
|
| 352 |
+
identityFunctionCheck: "never"
|
| 353 |
+
}
|
| 354 |
+
}) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
|
| 355 |
+
const currentState = useSelector((state) => querySelector(state, lastValue.current), import_react_redux2.shallowEqual);
|
| 356 |
+
const store = useStore();
|
| 357 |
+
const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
|
| 358 |
+
useIsomorphicLayoutEffect(() => {
|
| 359 |
+
lastValue.current = newLastValue;
|
| 360 |
+
}, [newLastValue]);
|
| 361 |
+
return currentState;
|
| 362 |
+
};
|
| 363 |
+
return useQueryState;
|
| 364 |
+
}
|
| 365 |
+
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
| 366 |
+
(0, import_react3.useEffect)(() => {
|
| 367 |
+
return () => {
|
| 368 |
+
promiseRef.current?.unsubscribe?.();
|
| 369 |
+
promiseRef.current = void 0;
|
| 370 |
+
};
|
| 371 |
+
}, [promiseRef]);
|
| 372 |
+
}
|
| 373 |
+
function refetchOrErrorIfUnmounted(promiseRef) {
|
| 374 |
+
if (!promiseRef.current) throw new Error(false ? _formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
|
| 375 |
+
return promiseRef.current.refetch();
|
| 376 |
+
}
|
| 377 |
+
function buildQueryHooks(endpointName) {
|
| 378 |
+
const useQuerySubscription = (arg, options = {}) => {
|
| 379 |
+
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
| 380 |
+
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
| 381 |
+
return (0, import_react3.useMemo)(() => ({
|
| 382 |
+
/**
|
| 383 |
+
* A method to manually refetch data for the query
|
| 384 |
+
*/
|
| 385 |
+
refetch: () => refetchOrErrorIfUnmounted(promiseRef)
|
| 386 |
+
}), [promiseRef]);
|
| 387 |
+
};
|
| 388 |
+
const useLazyQuerySubscription = ({
|
| 389 |
+
refetchOnReconnect,
|
| 390 |
+
refetchOnFocus,
|
| 391 |
+
pollingInterval = 0,
|
| 392 |
+
skipPollingIfUnfocused = false
|
| 393 |
+
} = {}) => {
|
| 394 |
+
const {
|
| 395 |
+
initiate
|
| 396 |
+
} = api.endpoints[endpointName];
|
| 397 |
+
const dispatch = useDispatch();
|
| 398 |
+
const [arg, setArg] = (0, import_react3.useState)(UNINITIALIZED_VALUE);
|
| 399 |
+
const promiseRef = (0, import_react3.useRef)(void 0);
|
| 400 |
+
const stableSubscriptionOptions = useShallowStableValue({
|
| 401 |
+
refetchOnReconnect,
|
| 402 |
+
refetchOnFocus,
|
| 403 |
+
pollingInterval,
|
| 404 |
+
skipPollingIfUnfocused
|
| 405 |
+
});
|
| 406 |
+
usePossiblyImmediateEffect(() => {
|
| 407 |
+
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
| 408 |
+
if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
| 409 |
+
promiseRef.current?.updateSubscriptionOptions(stableSubscriptionOptions);
|
| 410 |
+
}
|
| 411 |
+
}, [stableSubscriptionOptions]);
|
| 412 |
+
const subscriptionOptionsRef = (0, import_react3.useRef)(stableSubscriptionOptions);
|
| 413 |
+
usePossiblyImmediateEffect(() => {
|
| 414 |
+
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
| 415 |
+
}, [stableSubscriptionOptions]);
|
| 416 |
+
const trigger = (0, import_react3.useCallback)(function(arg2, preferCacheValue = false) {
|
| 417 |
+
let promise;
|
| 418 |
+
batch(() => {
|
| 419 |
+
promiseRef.current?.unsubscribe();
|
| 420 |
+
promiseRef.current = promise = dispatch(initiate(arg2, {
|
| 421 |
+
subscriptionOptions: subscriptionOptionsRef.current,
|
| 422 |
+
forceRefetch: !preferCacheValue
|
| 423 |
+
}));
|
| 424 |
+
setArg(arg2);
|
| 425 |
+
});
|
| 426 |
+
return promise;
|
| 427 |
+
}, [dispatch, initiate]);
|
| 428 |
+
const reset = (0, import_react3.useCallback)(() => {
|
| 429 |
+
if (promiseRef.current?.queryCacheKey) {
|
| 430 |
+
dispatch(api.internalActions.removeQueryResult({
|
| 431 |
+
queryCacheKey: promiseRef.current?.queryCacheKey
|
| 432 |
+
}));
|
| 433 |
+
}
|
| 434 |
+
}, [dispatch]);
|
| 435 |
+
(0, import_react3.useEffect)(() => {
|
| 436 |
+
return () => {
|
| 437 |
+
promiseRef?.current?.unsubscribe();
|
| 438 |
+
};
|
| 439 |
+
}, []);
|
| 440 |
+
(0, import_react3.useEffect)(() => {
|
| 441 |
+
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
| 442 |
+
trigger(arg, true);
|
| 443 |
+
}
|
| 444 |
+
}, [arg, trigger]);
|
| 445 |
+
return (0, import_react3.useMemo)(() => [trigger, arg, {
|
| 446 |
+
reset
|
| 447 |
+
}], [trigger, arg, reset]);
|
| 448 |
+
};
|
| 449 |
+
const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
|
| 450 |
+
return {
|
| 451 |
+
useQueryState,
|
| 452 |
+
useQuerySubscription,
|
| 453 |
+
useLazyQuerySubscription,
|
| 454 |
+
useLazyQuery(options) {
|
| 455 |
+
const [trigger, arg, {
|
| 456 |
+
reset
|
| 457 |
+
}] = useLazyQuerySubscription(options);
|
| 458 |
+
const queryStateResults = useQueryState(arg, {
|
| 459 |
+
...options,
|
| 460 |
+
skip: arg === UNINITIALIZED_VALUE
|
| 461 |
+
});
|
| 462 |
+
const info = (0, import_react3.useMemo)(() => ({
|
| 463 |
+
lastArg: arg
|
| 464 |
+
}), [arg]);
|
| 465 |
+
return (0, import_react3.useMemo)(() => [trigger, {
|
| 466 |
+
...queryStateResults,
|
| 467 |
+
reset
|
| 468 |
+
}, info], [trigger, queryStateResults, reset, info]);
|
| 469 |
+
},
|
| 470 |
+
useQuery(arg, options) {
|
| 471 |
+
const querySubscriptionResults = useQuerySubscription(arg, options);
|
| 472 |
+
const queryStateResults = useQueryState(arg, {
|
| 473 |
+
selectFromResult: arg === import_query.skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
| 474 |
+
...options
|
| 475 |
+
});
|
| 476 |
+
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
| 477 |
+
(0, import_react3.useDebugValue)(debugValue);
|
| 478 |
+
return (0, import_react3.useMemo)(() => ({
|
| 479 |
+
...queryStateResults,
|
| 480 |
+
...querySubscriptionResults
|
| 481 |
+
}), [queryStateResults, querySubscriptionResults]);
|
| 482 |
+
}
|
| 483 |
+
};
|
| 484 |
+
}
|
| 485 |
+
function buildInfiniteQueryHooks(endpointName) {
|
| 486 |
+
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
| 487 |
+
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
| 488 |
+
const subscriptionOptionsRef = (0, import_react3.useRef)(stableSubscriptionOptions);
|
| 489 |
+
usePossiblyImmediateEffect(() => {
|
| 490 |
+
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
| 491 |
+
}, [stableSubscriptionOptions]);
|
| 492 |
+
const trigger = (0, import_react3.useCallback)(function(arg2, direction) {
|
| 493 |
+
let promise;
|
| 494 |
+
batch(() => {
|
| 495 |
+
promiseRef.current?.unsubscribe();
|
| 496 |
+
promiseRef.current = promise = dispatch(initiate(arg2, {
|
| 497 |
+
subscriptionOptions: subscriptionOptionsRef.current,
|
| 498 |
+
direction
|
| 499 |
+
}));
|
| 500 |
+
});
|
| 501 |
+
return promise;
|
| 502 |
+
}, [promiseRef, dispatch, initiate]);
|
| 503 |
+
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
| 504 |
+
const stableArg = useStableQueryArgs(
|
| 505 |
+
options.skip ? import_query.skipToken : arg,
|
| 506 |
+
// Even if the user provided a per-endpoint `serializeQueryArgs` with
|
| 507 |
+
// a consistent return value, _here_ we want to use the default behavior
|
| 508 |
+
// so we can tell if _anything_ actually changed. Otherwise, we can end up
|
| 509 |
+
// with a case where the query args did change but the serialization doesn't,
|
| 510 |
+
// and then we never try to initiate a refetch.
|
| 511 |
+
import_query.defaultSerializeQueryArgs,
|
| 512 |
+
context.endpointDefinitions[endpointName],
|
| 513 |
+
endpointName
|
| 514 |
+
);
|
| 515 |
+
const refetch = (0, import_react3.useCallback)(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
|
| 516 |
+
return (0, import_react3.useMemo)(() => {
|
| 517 |
+
const fetchNextPage = () => {
|
| 518 |
+
return trigger(stableArg, "forward");
|
| 519 |
+
};
|
| 520 |
+
const fetchPreviousPage = () => {
|
| 521 |
+
return trigger(stableArg, "backward");
|
| 522 |
+
};
|
| 523 |
+
return {
|
| 524 |
+
trigger,
|
| 525 |
+
/**
|
| 526 |
+
* A method to manually refetch data for the query
|
| 527 |
+
*/
|
| 528 |
+
refetch,
|
| 529 |
+
fetchNextPage,
|
| 530 |
+
fetchPreviousPage
|
| 531 |
+
};
|
| 532 |
+
}, [refetch, trigger, stableArg]);
|
| 533 |
+
};
|
| 534 |
+
const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
|
| 535 |
+
return {
|
| 536 |
+
useInfiniteQueryState,
|
| 537 |
+
useInfiniteQuerySubscription,
|
| 538 |
+
useInfiniteQuery(arg, options) {
|
| 539 |
+
const {
|
| 540 |
+
refetch,
|
| 541 |
+
fetchNextPage,
|
| 542 |
+
fetchPreviousPage
|
| 543 |
+
} = useInfiniteQuerySubscription(arg, options);
|
| 544 |
+
const queryStateResults = useInfiniteQueryState(arg, {
|
| 545 |
+
selectFromResult: arg === import_query.skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
| 546 |
+
...options
|
| 547 |
+
});
|
| 548 |
+
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
| 549 |
+
(0, import_react3.useDebugValue)(debugValue);
|
| 550 |
+
return (0, import_react3.useMemo)(() => ({
|
| 551 |
+
...queryStateResults,
|
| 552 |
+
fetchNextPage,
|
| 553 |
+
fetchPreviousPage,
|
| 554 |
+
refetch
|
| 555 |
+
}), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
|
| 556 |
+
}
|
| 557 |
+
};
|
| 558 |
+
}
|
| 559 |
+
function buildMutationHook(name) {
|
| 560 |
+
return ({
|
| 561 |
+
selectFromResult,
|
| 562 |
+
fixedCacheKey
|
| 563 |
+
} = {}) => {
|
| 564 |
+
const {
|
| 565 |
+
select,
|
| 566 |
+
initiate
|
| 567 |
+
} = api.endpoints[name];
|
| 568 |
+
const dispatch = useDispatch();
|
| 569 |
+
const [promise, setPromise] = (0, import_react3.useState)();
|
| 570 |
+
(0, import_react3.useEffect)(() => () => {
|
| 571 |
+
if (!promise?.arg.fixedCacheKey) {
|
| 572 |
+
promise?.reset();
|
| 573 |
+
}
|
| 574 |
+
}, [promise]);
|
| 575 |
+
const triggerMutation = (0, import_react3.useCallback)(function(arg) {
|
| 576 |
+
const promise2 = dispatch(initiate(arg, {
|
| 577 |
+
fixedCacheKey
|
| 578 |
+
}));
|
| 579 |
+
setPromise(promise2);
|
| 580 |
+
return promise2;
|
| 581 |
+
}, [dispatch, initiate, fixedCacheKey]);
|
| 582 |
+
const {
|
| 583 |
+
requestId
|
| 584 |
+
} = promise || {};
|
| 585 |
+
const selectDefaultResult = (0, import_react3.useMemo)(() => select({
|
| 586 |
+
fixedCacheKey,
|
| 587 |
+
requestId: promise?.requestId
|
| 588 |
+
}), [fixedCacheKey, promise, select]);
|
| 589 |
+
const mutationSelector = (0, import_react3.useMemo)(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
| 590 |
+
const currentState = useSelector(mutationSelector, import_react_redux2.shallowEqual);
|
| 591 |
+
const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : void 0;
|
| 592 |
+
const reset = (0, import_react3.useCallback)(() => {
|
| 593 |
+
batch(() => {
|
| 594 |
+
if (promise) {
|
| 595 |
+
setPromise(void 0);
|
| 596 |
+
}
|
| 597 |
+
if (fixedCacheKey) {
|
| 598 |
+
dispatch(api.internalActions.removeMutationResult({
|
| 599 |
+
requestId,
|
| 600 |
+
fixedCacheKey
|
| 601 |
+
}));
|
| 602 |
+
}
|
| 603 |
+
});
|
| 604 |
+
}, [dispatch, fixedCacheKey, promise, requestId]);
|
| 605 |
+
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
| 606 |
+
(0, import_react3.useDebugValue)(debugValue);
|
| 607 |
+
const finalState = (0, import_react3.useMemo)(() => ({
|
| 608 |
+
...currentState,
|
| 609 |
+
originalArgs,
|
| 610 |
+
reset
|
| 611 |
+
}), [currentState, originalArgs, reset]);
|
| 612 |
+
return (0, import_react3.useMemo)(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
| 613 |
+
};
|
| 614 |
+
}
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
// src/query/react/module.ts
|
| 618 |
+
var reactHooksModuleName = /* @__PURE__ */ Symbol();
|
| 619 |
+
var reactHooksModule = ({
|
| 620 |
+
batch = import_react_redux3.batch,
|
| 621 |
+
hooks = {
|
| 622 |
+
useDispatch: import_react_redux3.useDispatch,
|
| 623 |
+
useSelector: import_react_redux3.useSelector,
|
| 624 |
+
useStore: import_react_redux3.useStore
|
| 625 |
+
},
|
| 626 |
+
createSelector = import_reselect.createSelector,
|
| 627 |
+
unstable__sideEffectsInRender = false,
|
| 628 |
+
...rest
|
| 629 |
+
} = {}) => {
|
| 630 |
+
if (true) {
|
| 631 |
+
const hookNames = ["useDispatch", "useSelector", "useStore"];
|
| 632 |
+
let warned = false;
|
| 633 |
+
for (const hookName of hookNames) {
|
| 634 |
+
if (countObjectKeys(rest) > 0) {
|
| 635 |
+
if (rest[hookName]) {
|
| 636 |
+
if (!warned) {
|
| 637 |
+
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 } })`");
|
| 638 |
+
warned = true;
|
| 639 |
+
}
|
| 640 |
+
}
|
| 641 |
+
hooks[hookName] = rest[hookName];
|
| 642 |
+
}
|
| 643 |
+
if (typeof hooks[hookName] !== "function") {
|
| 644 |
+
throw new Error(false ? _formatProdErrorMessage3(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(", ")}.
|
| 645 |
+
Hook ${hookName} was either not provided or not a function.`);
|
| 646 |
+
}
|
| 647 |
+
}
|
| 648 |
+
}
|
| 649 |
+
return {
|
| 650 |
+
name: reactHooksModuleName,
|
| 651 |
+
init(api, {
|
| 652 |
+
serializeQueryArgs
|
| 653 |
+
}, context) {
|
| 654 |
+
const anyApi = api;
|
| 655 |
+
const {
|
| 656 |
+
buildQueryHooks,
|
| 657 |
+
buildInfiniteQueryHooks,
|
| 658 |
+
buildMutationHook,
|
| 659 |
+
usePrefetch
|
| 660 |
+
} = buildHooks({
|
| 661 |
+
api,
|
| 662 |
+
moduleOptions: {
|
| 663 |
+
batch,
|
| 664 |
+
hooks,
|
| 665 |
+
unstable__sideEffectsInRender,
|
| 666 |
+
createSelector
|
| 667 |
+
},
|
| 668 |
+
serializeQueryArgs,
|
| 669 |
+
context
|
| 670 |
+
});
|
| 671 |
+
safeAssign(anyApi, {
|
| 672 |
+
usePrefetch
|
| 673 |
+
});
|
| 674 |
+
safeAssign(context, {
|
| 675 |
+
batch
|
| 676 |
+
});
|
| 677 |
+
return {
|
| 678 |
+
injectEndpoint(endpointName, definition) {
|
| 679 |
+
if (isQueryDefinition(definition)) {
|
| 680 |
+
const {
|
| 681 |
+
useQuery,
|
| 682 |
+
useLazyQuery,
|
| 683 |
+
useLazyQuerySubscription,
|
| 684 |
+
useQueryState,
|
| 685 |
+
useQuerySubscription
|
| 686 |
+
} = buildQueryHooks(endpointName);
|
| 687 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 688 |
+
useQuery,
|
| 689 |
+
useLazyQuery,
|
| 690 |
+
useLazyQuerySubscription,
|
| 691 |
+
useQueryState,
|
| 692 |
+
useQuerySubscription
|
| 693 |
+
});
|
| 694 |
+
api[`use${capitalize(endpointName)}Query`] = useQuery;
|
| 695 |
+
api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
|
| 696 |
+
}
|
| 697 |
+
if (isMutationDefinition(definition)) {
|
| 698 |
+
const useMutation = buildMutationHook(endpointName);
|
| 699 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 700 |
+
useMutation
|
| 701 |
+
});
|
| 702 |
+
api[`use${capitalize(endpointName)}Mutation`] = useMutation;
|
| 703 |
+
} else if (isInfiniteQueryDefinition(definition)) {
|
| 704 |
+
const {
|
| 705 |
+
useInfiniteQuery,
|
| 706 |
+
useInfiniteQuerySubscription,
|
| 707 |
+
useInfiniteQueryState
|
| 708 |
+
} = buildInfiniteQueryHooks(endpointName);
|
| 709 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 710 |
+
useInfiniteQuery,
|
| 711 |
+
useInfiniteQuerySubscription,
|
| 712 |
+
useInfiniteQueryState
|
| 713 |
+
});
|
| 714 |
+
api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
|
| 715 |
+
}
|
| 716 |
+
}
|
| 717 |
+
};
|
| 718 |
+
}
|
| 719 |
+
};
|
| 720 |
+
};
|
| 721 |
+
|
| 722 |
+
// src/query/react/index.ts
|
| 723 |
+
__reExport(react_exports, require("@reduxjs/toolkit/query"), module.exports);
|
| 724 |
+
|
| 725 |
+
// src/query/react/ApiProvider.tsx
|
| 726 |
+
var import_toolkit3 = require("@reduxjs/toolkit");
|
| 727 |
+
var import_react4 = require("react");
|
| 728 |
+
var import_react5 = require("react");
|
| 729 |
+
var React = __toESM(require("react"));
|
| 730 |
+
var import_react_redux4 = require("react-redux");
|
| 731 |
+
var import_query2 = require("@reduxjs/toolkit/query");
|
| 732 |
+
function ApiProvider(props) {
|
| 733 |
+
const context = props.context || import_react_redux4.ReactReduxContext;
|
| 734 |
+
const existingContext = (0, import_react4.useContext)(context);
|
| 735 |
+
if (existingContext) {
|
| 736 |
+
throw new Error(false ? _formatProdErrorMessage4(35) : "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.");
|
| 737 |
+
}
|
| 738 |
+
const [store] = React.useState(() => (0, import_toolkit3.configureStore)({
|
| 739 |
+
reducer: {
|
| 740 |
+
[props.api.reducerPath]: props.api.reducer
|
| 741 |
+
},
|
| 742 |
+
middleware: (gDM) => gDM().concat(props.api.middleware)
|
| 743 |
+
}));
|
| 744 |
+
(0, import_react5.useEffect)(() => props.setupListeners === false ? void 0 : (0, import_query2.setupListeners)(store.dispatch, props.setupListeners), [props.setupListeners, store.dispatch]);
|
| 745 |
+
return /* @__PURE__ */ React.createElement(import_react_redux4.Provider, { store, context }, props.children);
|
| 746 |
+
}
|
| 747 |
+
|
| 748 |
+
// src/query/react/index.ts
|
| 749 |
+
var createApi = /* @__PURE__ */ (0, import_query3.buildCreateApi)((0, import_query3.coreModule)(), reactHooksModule());
|
| 750 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 751 |
+
0 && (module.exports = {
|
| 752 |
+
ApiProvider,
|
| 753 |
+
UNINITIALIZED_VALUE,
|
| 754 |
+
createApi,
|
| 755 |
+
reactHooksModule,
|
| 756 |
+
reactHooksModuleName,
|
| 757 |
+
...require("@reduxjs/toolkit/query")
|
| 758 |
+
});
|
| 759 |
+
//# sourceMappingURL=rtk-query-react.development.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.development.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";var Pe=Object.create;var W=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var Ee=(e,s)=>{for(var d in s)W(e,d,{get:s[d],enumerable:!0})},j=(e,s,d,R)=>{if(s&&typeof s=="object"||typeof s=="function")for(let T of Ie(s))!be.call(e,T)&&T!==d&&W(e,T,{get:()=>s[T],enumerable:!(R=he(s,T))||R.enumerable});return e},k=(e,s,d)=>(j(e,s,"default"),d&&j(d,s,"default")),ke=(e,s,d)=>(d=e!=null?Pe(Ue(e)):{},j(s||!e||!e.__esModule?W(d,"default",{value:e,enumerable:!0}):d,e)),Me=e=>j(W({},"__esModule",{value:!0}),e);var E={};Ee(E,{ApiProvider:()=>Se,UNINITIALIZED_VALUE:()=>H,createApi:()=>Ne,reactHooksModule:()=>Qe,reactHooksModuleName:()=>fe});module.exports=Me(E);var te=require("@reduxjs/toolkit/query");var Xe=require("@reduxjs/toolkit"),M=require("react-redux"),Te=require("reselect");function V(e){return e.replace(e[0],e[0].toUpperCase())}function de(e){return e.type==="query"}function ce(e){return e.type==="mutation"}function $(e){return e.type==="infinitequery"}function N(e,...s){return Object.assign(e,...s)}var ge=require("@reduxjs/toolkit"),A=require("@reduxjs/toolkit/query"),n=require("react"),Y=require("react-redux");var H=Symbol();var z=require("react");function G(e,s,d,R){let T=(0,z.useMemo)(()=>({queryArgs:e,serialized:typeof e=="object"?s({queryArgs:e,endpointDefinition:d,endpointName:R}):e}),[e,s,d,R]),D=(0,z.useRef)(T);return(0,z.useEffect)(()=>{D.current.serialized!==T.serialized&&(D.current=T)},[T]),D.current.serialized===T.serialized?D.current.queryArgs:e}var Z=require("react"),ye=require("react-redux");function _(e){let s=(0,Z.useRef)(e);return(0,Z.useEffect)(()=>{(0,ye.shallowEqual)(s.current,e)||(s.current=e)},[e]),(0,ye.shallowEqual)(s.current,e)?s.current:e}var Oe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Fe=Oe(),we=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ve=we(),Le=()=>Fe||ve?n.useLayoutEffect:n.useEffect,Ce=Le(),le=e=>e.isUninitialized?{...e,isUninitialized:!1,isFetching:!0,isLoading:e.data===void 0,status:A.QueryStatus.pending}:e;function oe(e,...s){let d={};return s.forEach(R=>{d[R]=e[R]}),d}var pe=["data","status","isLoading","isSuccess","isError","error"];function Re({api:e,moduleOptions:{batch:s,hooks:{useDispatch:d,useSelector:R,useStore:T},unstable__sideEffectsInRender:D,createSelector:L},serializeQueryArgs:U,context:h}){let O=D?t=>t():n.useEffect;return{buildQueryHooks:q,buildInfiniteQueryHooks:se,buildMutationHook:ae,usePrefetch:ie};function ne(t,a,Q){if(a?.endpointName&&t.isUninitialized){let{endpointName:y}=a,p=h.endpointDefinitions[y];Q!==A.skipToken&&U({queryArgs:a.originalArgs,endpointDefinition:p,endpointName:y})===U({queryArgs:Q,endpointDefinition:p,endpointName:y})&&(a=void 0)}let o=t.isSuccess?t.data:a?.data;o===void 0&&(o=t.data);let u=o!==void 0,r=t.isLoading,i=(!a||a.isLoading||a.isUninitialized)&&!u&&r,f=t.isSuccess||u&&(r&&!a?.isError||t.isUninitialized);return{...t,data:o,currentData:t.data,isFetching:r,isLoading:i,isSuccess:f}}function re(t,a,Q){if(a?.endpointName&&t.isUninitialized){let{endpointName:y}=a,p=h.endpointDefinitions[y];Q!==A.skipToken&&U({queryArgs:a.originalArgs,endpointDefinition:p,endpointName:y})===U({queryArgs:Q,endpointDefinition:p,endpointName:y})&&(a=void 0)}let o=t.isSuccess?t.data:a?.data;o===void 0&&(o=t.data);let u=o!==void 0,r=t.isLoading,i=(!a||a.isLoading||a.isUninitialized)&&!u&&r,f=t.isSuccess||r&&u;return{...t,data:o,currentData:t.data,isFetching:r,isLoading:i,isSuccess:f}}function ie(t,a){let Q=d(),o=_(a);return(0,n.useCallback)((u,r)=>Q(e.util.prefetch(t,u,{...o,...r})),[t,Q,o])}function B(t,a,{refetchOnReconnect:Q,refetchOnFocus:o,refetchOnMountOrArgChange:u,skip:r=!1,pollingInterval:i=0,skipPollingIfUnfocused:f=!1,...y}={}){let{initiate:p}=e.endpoints[t],l=d(),P=(0,n.useRef)(void 0);if(!P.current){let v=l(e.internalActions.internal_getRTKQSubscriptions());P.current=v}let c=G(r?A.skipToken:a,A.defaultSerializeQueryArgs,h.endpointDefinitions[t],t),g=_({refetchOnReconnect:Q,refetchOnFocus:o,pollingInterval:i,skipPollingIfUnfocused:f}),x=y.initialPageParam,m=_(x),S=(0,n.useRef)(void 0),{queryCacheKey:b,requestId:w}=S.current||{},K=!1;b&&w&&(K=P.current.isRequestSubscribed(b,w));let ue=!K&&S.current!==void 0;return O(()=>{ue&&(S.current=void 0)},[ue]),O(()=>{let v=S.current;if(typeof process<"u",c===A.skipToken){v?.unsubscribe(),S.current=void 0;return}let Ae=S.current?.subscriptionOptions;if(!v||v.arg!==c){v?.unsubscribe();let Be=l(p(c,{subscriptionOptions:g,forceRefetch:u,...$(h.endpointDefinitions[t])?{initialPageParam:m}:{}}));S.current=Be}else g!==Ae&&v.updateSubscriptionOptions(g)},[l,p,u,c,g,ue,m,t]),[S,l,p,g]}function C(t,a){return(o,{skip:u=!1,selectFromResult:r}={})=>{let{select:i}=e.endpoints[t],f=G(u?A.skipToken:o,U,h.endpointDefinitions[t],t),y=(0,n.useRef)(void 0),p=(0,n.useMemo)(()=>L([i(f),(x,m)=>m,x=>f],a,{memoizeOptions:{resultEqualityCheck:Y.shallowEqual}}),[i,f]),l=(0,n.useMemo)(()=>r?L([p],r,{devModeChecks:{identityFunctionCheck:"never"}}):p,[p,r]),P=R(x=>l(x,y.current),Y.shallowEqual),c=T(),g=p(c.getState(),y.current);return Ce(()=>{y.current=g},[g]),P}}function I(t){(0,n.useEffect)(()=>()=>{t.current?.unsubscribe?.(),t.current=void 0},[t])}function F(t){if(!t.current)throw new Error((0,ge.formatProdErrorMessage)(38));return t.current.refetch()}function q(t){let a=(u,r={})=>{let[i]=B(t,u,r);return I(i),(0,n.useMemo)(()=>({refetch:()=>F(i)}),[i])},Q=({refetchOnReconnect:u,refetchOnFocus:r,pollingInterval:i=0,skipPollingIfUnfocused:f=!1}={})=>{let{initiate:y}=e.endpoints[t],p=d(),[l,P]=(0,n.useState)(H),c=(0,n.useRef)(void 0),g=_({refetchOnReconnect:u,refetchOnFocus:r,pollingInterval:i,skipPollingIfUnfocused:f});O(()=>{let b=c.current?.subscriptionOptions;g!==b&&c.current?.updateSubscriptionOptions(g)},[g]);let x=(0,n.useRef)(g);O(()=>{x.current=g},[g]);let m=(0,n.useCallback)(function(b,w=!1){let K;return s(()=>{c.current?.unsubscribe(),c.current=K=p(y(b,{subscriptionOptions:x.current,forceRefetch:!w})),P(b)}),K},[p,y]),S=(0,n.useCallback)(()=>{c.current?.queryCacheKey&&p(e.internalActions.removeQueryResult({queryCacheKey:c.current?.queryCacheKey}))},[p]);return(0,n.useEffect)(()=>()=>{c?.current?.unsubscribe()},[]),(0,n.useEffect)(()=>{l!==H&&!c.current&&m(l,!0)},[l,m]),(0,n.useMemo)(()=>[m,l,{reset:S}],[m,l,S])},o=C(t,ne);return{useQueryState:o,useQuerySubscription:a,useLazyQuerySubscription:Q,useLazyQuery(u){let[r,i,{reset:f}]=Q(u),y=o(i,{...u,skip:i===H}),p=(0,n.useMemo)(()=>({lastArg:i}),[i]);return(0,n.useMemo)(()=>[r,{...y,reset:f},p],[r,y,f,p])},useQuery(u,r){let i=a(u,r),f=o(u,{selectFromResult:u===A.skipToken||r?.skip?void 0:le,...r}),y=oe(f,...pe);return(0,n.useDebugValue)(y),(0,n.useMemo)(()=>({...f,...i}),[f,i])}}}function se(t){let a=(o,u={})=>{let[r,i,f,y]=B(t,o,u),p=(0,n.useRef)(y);O(()=>{p.current=y},[y]);let l=(0,n.useCallback)(function(g,x){let m;return s(()=>{r.current?.unsubscribe(),r.current=m=i(f(g,{subscriptionOptions:p.current,direction:x}))}),m},[r,i,f]);I(r);let P=G(u.skip?A.skipToken:o,A.defaultSerializeQueryArgs,h.endpointDefinitions[t],t),c=(0,n.useCallback)(()=>F(r),[r]);return(0,n.useMemo)(()=>({trigger:l,refetch:c,fetchNextPage:()=>l(P,"forward"),fetchPreviousPage:()=>l(P,"backward")}),[c,l,P])},Q=C(t,re);return{useInfiniteQueryState:Q,useInfiniteQuerySubscription:a,useInfiniteQuery(o,u){let{refetch:r,fetchNextPage:i,fetchPreviousPage:f}=a(o,u),y=Q(o,{selectFromResult:o===A.skipToken||u?.skip?void 0:le,...u}),p=oe(y,...pe,"hasNextPage","hasPreviousPage");return(0,n.useDebugValue)(p),(0,n.useMemo)(()=>({...y,fetchNextPage:i,fetchPreviousPage:f,refetch:r}),[y,i,f,r])}}}function ae(t){return({selectFromResult:a,fixedCacheKey:Q}={})=>{let{select:o,initiate:u}=e.endpoints[t],r=d(),[i,f]=(0,n.useState)();(0,n.useEffect)(()=>()=>{i?.arg.fixedCacheKey||i?.reset()},[i]);let y=(0,n.useCallback)(function(b){let w=r(u(b,{fixedCacheKey:Q}));return f(w),w},[r,u,Q]),{requestId:p}=i||{},l=(0,n.useMemo)(()=>o({fixedCacheKey:Q,requestId:i?.requestId}),[Q,i,o]),P=(0,n.useMemo)(()=>a?L([l],a):l,[a,l]),c=R(P,Y.shallowEqual),g=Q==null?i?.arg.originalArgs:void 0,x=(0,n.useCallback)(()=>{s(()=>{i&&f(void 0),Q&&r(e.internalActions.removeMutationResult({requestId:p,fixedCacheKey:Q}))})},[r,Q,i,p]),m=oe(c,...pe,"endpointName");(0,n.useDebugValue)(m);let S=(0,n.useMemo)(()=>({...c,originalArgs:g,reset:x}),[c,g,x]);return(0,n.useMemo)(()=>[y,S],[y,S])}}}var fe=Symbol(),Qe=({batch:e=M.batch,hooks:s={useDispatch:M.useDispatch,useSelector:M.useSelector,useStore:M.useStore},createSelector:d=Te.createSelector,unstable__sideEffectsInRender:R=!1,...T}={})=>({name:fe,init(D,{serializeQueryArgs:L},U){let h=D,{buildQueryHooks:O,buildInfiniteQueryHooks:ne,buildMutationHook:re,usePrefetch:ie}=Re({api:D,moduleOptions:{batch:e,hooks:s,unstable__sideEffectsInRender:R,createSelector:d},serializeQueryArgs:L,context:U});return N(h,{usePrefetch:ie}),N(U,{batch:e}),{injectEndpoint(B,C){if(de(C)){let{useQuery:I,useLazyQuery:F,useLazyQuerySubscription:q,useQueryState:se,useQuerySubscription:ae}=O(B);N(h.endpoints[B],{useQuery:I,useLazyQuery:F,useLazyQuerySubscription:q,useQueryState:se,useQuerySubscription:ae}),D[`use${V(B)}Query`]=I,D[`useLazy${V(B)}Query`]=F}if(ce(C)){let I=re(B);N(h.endpoints[B],{useMutation:I}),D[`use${V(B)}Mutation`]=I}else if($(C)){let{useInfiniteQuery:I,useInfiniteQuerySubscription:F,useInfiniteQueryState:q}=ne(B);N(h.endpoints[B],{useInfiniteQuery:I,useInfiniteQuerySubscription:F,useInfiniteQueryState:q}),D[`use${V(B)}InfiniteQuery`]=I}}}}});k(E,require("@reduxjs/toolkit/query"),module.exports);var J=require("@reduxjs/toolkit"),De=require("react"),xe=require("react"),X=ke(require("react")),ee=require("react-redux"),me=require("@reduxjs/toolkit/query");function Se(e){let s=e.context||ee.ReactReduxContext;if((0,De.useContext)(s))throw new Error((0,J.formatProdErrorMessage)(35));let[R]=X.useState(()=>(0,J.configureStore)({reducer:{[e.api.reducerPath]:e.api.reducer},middleware:T=>T().concat(e.api.middleware)}));return(0,xe.useEffect)(()=>e.setupListeners===!1?void 0:(0,me.setupListeners)(R.dispatch,e.setupListeners),[e.setupListeners,R.dispatch]),X.createElement(ee.Provider,{store:R,context:s},e.children)}var Ne=(0,te.buildCreateApi)((0,te.coreModule)(),Qe());0&&(module.exports={ApiProvider,UNINITIALIZED_VALUE,createApi,reactHooksModule,reactHooksModuleName,...require("@reduxjs/toolkit/query")});
|
| 2 |
+
//# sourceMappingURL=rtk-query-react.production.min.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/cjs/rtk-query-react.production.min.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.mts
ADDED
|
@@ -0,0 +1,959 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
| 2 |
+
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';
|
| 3 |
+
export * from '@reduxjs/toolkit/query';
|
| 4 |
+
import * as react_redux from 'react-redux';
|
| 5 |
+
import { ReactReduxContextValue } from 'react-redux';
|
| 6 |
+
import { createSelector } from 'reselect';
|
| 7 |
+
import * as React from 'react';
|
| 8 |
+
import { Context } from 'react';
|
| 9 |
+
|
| 10 |
+
type InfiniteData<DataType, PageParam> = {
|
| 11 |
+
pages: Array<DataType>;
|
| 12 |
+
pageParams: Array<PageParam>;
|
| 13 |
+
};
|
| 14 |
+
type InfiniteQueryDirection = 'forward' | 'backward';
|
| 15 |
+
|
| 16 |
+
export declare const UNINITIALIZED_VALUE: unique symbol;
|
| 17 |
+
type UninitializedValue = typeof UNINITIALIZED_VALUE;
|
| 18 |
+
|
| 19 |
+
type QueryHooks<Definition extends QueryDefinition<any, any, any, any, any>> = {
|
| 20 |
+
useQuery: UseQuery<Definition>;
|
| 21 |
+
useLazyQuery: UseLazyQuery<Definition>;
|
| 22 |
+
useQuerySubscription: UseQuerySubscription<Definition>;
|
| 23 |
+
useLazyQuerySubscription: UseLazyQuerySubscription<Definition>;
|
| 24 |
+
useQueryState: UseQueryState<Definition>;
|
| 25 |
+
};
|
| 26 |
+
type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
| 27 |
+
useInfiniteQuery: UseInfiniteQuery<Definition>;
|
| 28 |
+
useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;
|
| 29 |
+
useInfiniteQueryState: UseInfiniteQueryState<Definition>;
|
| 30 |
+
};
|
| 31 |
+
type MutationHooks<Definition extends MutationDefinition<any, any, any, any, any>> = {
|
| 32 |
+
useMutation: UseMutation<Definition>;
|
| 33 |
+
};
|
| 34 |
+
/**
|
| 35 |
+
* 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.
|
| 36 |
+
*
|
| 37 |
+
* 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.
|
| 38 |
+
*
|
| 39 |
+
* This hook combines the functionality of both [`useQueryState`](#usequerystate) and [`useQuerySubscription`](#usequerysubscription) together, and is intended to be used in the majority of situations.
|
| 40 |
+
*
|
| 41 |
+
* #### Features
|
| 42 |
+
*
|
| 43 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 44 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 45 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 46 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 47 |
+
* - Re-renders as the request status changes and data becomes available
|
| 48 |
+
*/
|
| 49 |
+
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>;
|
| 50 |
+
type TypedUseQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 51 |
+
type UseQueryHookResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & UseQuerySubscriptionResult<D>;
|
| 52 |
+
/**
|
| 53 |
+
* Helper type to manually type the result
|
| 54 |
+
* of the `useQuery` hook in userland code.
|
| 55 |
+
*/
|
| 56 |
+
type TypedUseQueryHookResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery, R> & TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery>;
|
| 57 |
+
type UseQuerySubscriptionOptions = SubscriptionOptions & {
|
| 58 |
+
/**
|
| 59 |
+
* Prevents a query from automatically running.
|
| 60 |
+
*
|
| 61 |
+
* @remarks
|
| 62 |
+
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
| 63 |
+
*
|
| 64 |
+
* - **If the query has cached data:**
|
| 65 |
+
* * 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
|
| 66 |
+
* * The query will have a status of `uninitialized`
|
| 67 |
+
* * If `skip: false` is set after the initial load, the cached result will be used
|
| 68 |
+
* - **If the query does not have cached data:**
|
| 69 |
+
* * The query will have a status of `uninitialized`
|
| 70 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 71 |
+
* * The query will not automatically fetch on mount
|
| 72 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 73 |
+
*
|
| 74 |
+
* @example
|
| 75 |
+
* ```tsx
|
| 76 |
+
* // codeblock-meta no-transpile title="Skip example"
|
| 77 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 78 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 79 |
+
* skip,
|
| 80 |
+
* });
|
| 81 |
+
*
|
| 82 |
+
* return (
|
| 83 |
+
* <div>
|
| 84 |
+
* {name} - {status}
|
| 85 |
+
* </div>
|
| 86 |
+
* );
|
| 87 |
+
* };
|
| 88 |
+
* ```
|
| 89 |
+
*/
|
| 90 |
+
skip?: boolean;
|
| 91 |
+
/**
|
| 92 |
+
* 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.
|
| 93 |
+
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
| 94 |
+
* - `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.
|
| 95 |
+
* - `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.
|
| 96 |
+
*
|
| 97 |
+
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
| 98 |
+
*/
|
| 99 |
+
refetchOnMountOrArgChange?: boolean | number;
|
| 100 |
+
};
|
| 101 |
+
/**
|
| 102 |
+
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.
|
| 103 |
+
*
|
| 104 |
+
* 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.
|
| 105 |
+
*
|
| 106 |
+
* Note that this hook does not return a request status or cached data. For that use-case, see [`useQuery`](#usequery) or [`useQueryState`](#usequerystate).
|
| 107 |
+
*
|
| 108 |
+
* #### Features
|
| 109 |
+
*
|
| 110 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 111 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 112 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 113 |
+
*/
|
| 114 |
+
type UseQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions) => UseQuerySubscriptionResult<D>;
|
| 115 |
+
type TypedUseQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 116 |
+
type UseQuerySubscriptionResult<D extends QueryDefinition<any, any, any, any>> = Pick<QueryActionCreatorResult<D>, 'refetch'>;
|
| 117 |
+
/**
|
| 118 |
+
* Helper type to manually type the result
|
| 119 |
+
* of the `useQuerySubscription` hook in userland code.
|
| 120 |
+
*/
|
| 121 |
+
type TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscriptionResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 122 |
+
type UseLazyQueryLastPromiseInfo<D extends QueryDefinition<any, any, any, any>> = {
|
| 123 |
+
lastArg: QueryArgFrom<D>;
|
| 124 |
+
};
|
| 125 |
+
/**
|
| 126 |
+
* A React hook similar to [`useQuery`](#usequery), but with manual control over when the data fetching occurs.
|
| 127 |
+
*
|
| 128 |
+
* This hook includes the functionality of [`useLazyQuerySubscription`](#uselazyquerysubscription).
|
| 129 |
+
*
|
| 130 |
+
* #### Features
|
| 131 |
+
*
|
| 132 |
+
* - Manual control over firing a request to retrieve data
|
| 133 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 134 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 135 |
+
* - Re-renders as the request status changes and data becomes available
|
| 136 |
+
* - 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
|
| 137 |
+
*
|
| 138 |
+
* #### Note
|
| 139 |
+
*
|
| 140 |
+
* 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.
|
| 141 |
+
*/
|
| 142 |
+
type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>) => [
|
| 143 |
+
LazyQueryTrigger<D>,
|
| 144 |
+
UseLazyQueryStateResult<D, R>,
|
| 145 |
+
UseLazyQueryLastPromiseInfo<D>
|
| 146 |
+
];
|
| 147 |
+
type TypedUseLazyQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 148 |
+
type UseLazyQueryStateResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & {
|
| 149 |
+
/**
|
| 150 |
+
* Resets the hook state to its initial `uninitialized` state.
|
| 151 |
+
* This will also remove the last result from the cache.
|
| 152 |
+
*/
|
| 153 |
+
reset: () => void;
|
| 154 |
+
};
|
| 155 |
+
/**
|
| 156 |
+
* Helper type to manually type the result
|
| 157 |
+
* of the `useLazyQuery` hook in userland code.
|
| 158 |
+
*/
|
| 159 |
+
type TypedUseLazyQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseLazyQueryStateResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
| 160 |
+
type LazyQueryTrigger<D extends QueryDefinition<any, any, any, any>> = {
|
| 161 |
+
/**
|
| 162 |
+
* Triggers a lazy query.
|
| 163 |
+
*
|
| 164 |
+
* By default, this will start a new request even if there is already a value in the cache.
|
| 165 |
+
* 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`.
|
| 166 |
+
*
|
| 167 |
+
* @remarks
|
| 168 |
+
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
| 169 |
+
*
|
| 170 |
+
* @example
|
| 171 |
+
* ```ts
|
| 172 |
+
* // codeblock-meta title="Using .unwrap with async await"
|
| 173 |
+
* try {
|
| 174 |
+
* const payload = await getUserById(1).unwrap();
|
| 175 |
+
* console.log('fulfilled', payload)
|
| 176 |
+
* } catch (error) {
|
| 177 |
+
* console.error('rejected', error);
|
| 178 |
+
* }
|
| 179 |
+
* ```
|
| 180 |
+
*/
|
| 181 |
+
(arg: QueryArgFrom<D>, preferCacheValue?: boolean): QueryActionCreatorResult<D>;
|
| 182 |
+
};
|
| 183 |
+
type TypedLazyQueryTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = LazyQueryTrigger<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 184 |
+
/**
|
| 185 |
+
* A React hook similar to [`useQuerySubscription`](#usequerysubscription), but with manual control over when the data fetching occurs.
|
| 186 |
+
*
|
| 187 |
+
* Note that this hook does not return a request status or cached data. For that use-case, see [`useLazyQuery`](#uselazyquery).
|
| 188 |
+
*
|
| 189 |
+
* #### Features
|
| 190 |
+
*
|
| 191 |
+
* - Manual control over firing a request to retrieve data
|
| 192 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 193 |
+
* - 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
|
| 194 |
+
*/
|
| 195 |
+
type UseLazyQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (options?: SubscriptionOptions) => readonly [
|
| 196 |
+
LazyQueryTrigger<D>,
|
| 197 |
+
QueryArgFrom<D> | UninitializedValue,
|
| 198 |
+
{
|
| 199 |
+
reset: () => void;
|
| 200 |
+
}
|
| 201 |
+
];
|
| 202 |
+
type TypedUseLazyQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 203 |
+
/**
|
| 204 |
+
* @internal
|
| 205 |
+
*/
|
| 206 |
+
type QueryStateSelector<R extends Record<string, any>, D extends QueryDefinition<any, any, any, any>> = (state: UseQueryStateDefaultResult<D>) => R;
|
| 207 |
+
/**
|
| 208 |
+
* Provides a way to define a strongly-typed version of
|
| 209 |
+
* {@linkcode QueryStateSelector} for use with a specific query.
|
| 210 |
+
* This is useful for scenarios where you want to create a "pre-typed"
|
| 211 |
+
* {@linkcode UseQueryStateOptions.selectFromResult | selectFromResult}
|
| 212 |
+
* function.
|
| 213 |
+
*
|
| 214 |
+
* @example
|
| 215 |
+
* <caption>#### __Create a strongly-typed `selectFromResult` selector function__</caption>
|
| 216 |
+
*
|
| 217 |
+
* ```tsx
|
| 218 |
+
* import type { TypedQueryStateSelector } from '@reduxjs/toolkit/query/react'
|
| 219 |
+
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
| 220 |
+
*
|
| 221 |
+
* type Post = {
|
| 222 |
+
* id: number
|
| 223 |
+
* title: string
|
| 224 |
+
* }
|
| 225 |
+
*
|
| 226 |
+
* type PostsApiResponse = {
|
| 227 |
+
* posts: Post[]
|
| 228 |
+
* total: number
|
| 229 |
+
* skip: number
|
| 230 |
+
* limit: number
|
| 231 |
+
* }
|
| 232 |
+
*
|
| 233 |
+
* type QueryArgument = number | undefined
|
| 234 |
+
*
|
| 235 |
+
* type BaseQueryFunction = ReturnType<typeof fetchBaseQuery>
|
| 236 |
+
*
|
| 237 |
+
* type SelectedResult = Pick<PostsApiResponse, 'posts'>
|
| 238 |
+
*
|
| 239 |
+
* const postsApiSlice = createApi({
|
| 240 |
+
* baseQuery: fetchBaseQuery({ baseUrl: 'https://dummyjson.com/posts' }),
|
| 241 |
+
* reducerPath: 'postsApi',
|
| 242 |
+
* tagTypes: ['Posts'],
|
| 243 |
+
* endpoints: (build) => ({
|
| 244 |
+
* getPosts: build.query<PostsApiResponse, QueryArgument>({
|
| 245 |
+
* query: (limit = 5) => `?limit=${limit}&select=title`,
|
| 246 |
+
* }),
|
| 247 |
+
* }),
|
| 248 |
+
* })
|
| 249 |
+
*
|
| 250 |
+
* const { useGetPostsQuery } = postsApiSlice
|
| 251 |
+
*
|
| 252 |
+
* function PostById({ id }: { id: number }) {
|
| 253 |
+
* const { post } = useGetPostsQuery(undefined, {
|
| 254 |
+
* selectFromResult: (state) => ({
|
| 255 |
+
* post: state.data?.posts.find((post) => post.id === id),
|
| 256 |
+
* }),
|
| 257 |
+
* })
|
| 258 |
+
*
|
| 259 |
+
* return <li>{post?.title}</li>
|
| 260 |
+
* }
|
| 261 |
+
*
|
| 262 |
+
* const EMPTY_ARRAY: Post[] = []
|
| 263 |
+
*
|
| 264 |
+
* const typedSelectFromResult: TypedQueryStateSelector<
|
| 265 |
+
* PostsApiResponse,
|
| 266 |
+
* QueryArgument,
|
| 267 |
+
* BaseQueryFunction,
|
| 268 |
+
* SelectedResult
|
| 269 |
+
* > = (state) => ({ posts: state.data?.posts ?? EMPTY_ARRAY })
|
| 270 |
+
*
|
| 271 |
+
* function PostsList() {
|
| 272 |
+
* const { posts } = useGetPostsQuery(undefined, {
|
| 273 |
+
* selectFromResult: typedSelectFromResult,
|
| 274 |
+
* })
|
| 275 |
+
*
|
| 276 |
+
* return (
|
| 277 |
+
* <div>
|
| 278 |
+
* <ul>
|
| 279 |
+
* {posts.map((post) => (
|
| 280 |
+
* <PostById key={post.id} id={post.id} />
|
| 281 |
+
* ))}
|
| 282 |
+
* </ul>
|
| 283 |
+
* </div>
|
| 284 |
+
* )
|
| 285 |
+
* }
|
| 286 |
+
* ```
|
| 287 |
+
*
|
| 288 |
+
* @template ResultType - The type of the result `data` returned by the query.
|
| 289 |
+
* @template QueryArgumentType - The type of the argument passed into the query.
|
| 290 |
+
* @template BaseQueryFunctionType - The type of the base query function being used.
|
| 291 |
+
* @template SelectedResultType - The type of the selected result returned by the __`selectFromResult`__ function.
|
| 292 |
+
*
|
| 293 |
+
* @since 2.3.0
|
| 294 |
+
* @public
|
| 295 |
+
*/
|
| 296 |
+
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>>;
|
| 297 |
+
/**
|
| 298 |
+
* 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.
|
| 299 |
+
*
|
| 300 |
+
* Note that this hook does not trigger fetching new data. For that use-case, see [`useQuery`](#usequery) or [`useQuerySubscription`](#usequerysubscription).
|
| 301 |
+
*
|
| 302 |
+
* #### Features
|
| 303 |
+
*
|
| 304 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 305 |
+
* - Re-renders as the request status changes and data becomes available
|
| 306 |
+
*/
|
| 307 |
+
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>;
|
| 308 |
+
type TypedUseQueryState<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQueryState<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 309 |
+
/**
|
| 310 |
+
* @internal
|
| 311 |
+
*/
|
| 312 |
+
type UseQueryStateOptions<D extends QueryDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
| 313 |
+
/**
|
| 314 |
+
* Prevents a query from automatically running.
|
| 315 |
+
*
|
| 316 |
+
* @remarks
|
| 317 |
+
* When skip is true:
|
| 318 |
+
*
|
| 319 |
+
* - **If the query has cached data:**
|
| 320 |
+
* * 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
|
| 321 |
+
* * The query will have a status of `uninitialized`
|
| 322 |
+
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
| 323 |
+
* - **If the query does not have cached data:**
|
| 324 |
+
* * The query will have a status of `uninitialized`
|
| 325 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 326 |
+
* * The query will not automatically fetch on mount
|
| 327 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 328 |
+
*
|
| 329 |
+
* @example
|
| 330 |
+
* ```ts
|
| 331 |
+
* // codeblock-meta title="Skip example"
|
| 332 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 333 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 334 |
+
* skip,
|
| 335 |
+
* });
|
| 336 |
+
*
|
| 337 |
+
* return (
|
| 338 |
+
* <div>
|
| 339 |
+
* {name} - {status}
|
| 340 |
+
* </div>
|
| 341 |
+
* );
|
| 342 |
+
* };
|
| 343 |
+
* ```
|
| 344 |
+
*/
|
| 345 |
+
skip?: boolean;
|
| 346 |
+
/**
|
| 347 |
+
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
| 348 |
+
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
| 349 |
+
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
| 350 |
+
*
|
| 351 |
+
* @example
|
| 352 |
+
* ```ts
|
| 353 |
+
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
| 354 |
+
* function PostsList() {
|
| 355 |
+
* const { data: posts } = api.useGetPostsQuery();
|
| 356 |
+
*
|
| 357 |
+
* return (
|
| 358 |
+
* <ul>
|
| 359 |
+
* {posts?.data?.map((post) => (
|
| 360 |
+
* <PostById key={post.id} id={post.id} />
|
| 361 |
+
* ))}
|
| 362 |
+
* </ul>
|
| 363 |
+
* );
|
| 364 |
+
* }
|
| 365 |
+
*
|
| 366 |
+
* function PostById({ id }: { id: number }) {
|
| 367 |
+
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
| 368 |
+
* const { post } = api.useGetPostsQuery(undefined, {
|
| 369 |
+
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
| 370 |
+
* });
|
| 371 |
+
*
|
| 372 |
+
* return <li>{post?.name}</li>;
|
| 373 |
+
* }
|
| 374 |
+
* ```
|
| 375 |
+
*/
|
| 376 |
+
selectFromResult?: QueryStateSelector<R, D>;
|
| 377 |
+
};
|
| 378 |
+
/**
|
| 379 |
+
* Provides a way to define a "pre-typed" version of
|
| 380 |
+
* {@linkcode UseQueryStateOptions} with specific options for a given query.
|
| 381 |
+
* This is particularly useful for setting default query behaviors such as
|
| 382 |
+
* refetching strategies, which can be overridden as needed.
|
| 383 |
+
*
|
| 384 |
+
* @example
|
| 385 |
+
* <caption>#### __Create a `useQuery` hook with default options__</caption>
|
| 386 |
+
*
|
| 387 |
+
* ```ts
|
| 388 |
+
* import type {
|
| 389 |
+
* SubscriptionOptions,
|
| 390 |
+
* TypedUseQueryStateOptions,
|
| 391 |
+
* } from '@reduxjs/toolkit/query/react'
|
| 392 |
+
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
| 393 |
+
*
|
| 394 |
+
* type Post = {
|
| 395 |
+
* id: number
|
| 396 |
+
* name: string
|
| 397 |
+
* }
|
| 398 |
+
*
|
| 399 |
+
* const api = createApi({
|
| 400 |
+
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
|
| 401 |
+
* tagTypes: ['Post'],
|
| 402 |
+
* endpoints: (build) => ({
|
| 403 |
+
* getPosts: build.query<Post[], void>({
|
| 404 |
+
* query: () => 'posts',
|
| 405 |
+
* }),
|
| 406 |
+
* }),
|
| 407 |
+
* })
|
| 408 |
+
*
|
| 409 |
+
* const { useGetPostsQuery } = api
|
| 410 |
+
*
|
| 411 |
+
* export const useGetPostsQueryWithDefaults = <
|
| 412 |
+
* SelectedResult extends Record<string, any>,
|
| 413 |
+
* >(
|
| 414 |
+
* overrideOptions: TypedUseQueryStateOptions<
|
| 415 |
+
* Post[],
|
| 416 |
+
* void,
|
| 417 |
+
* ReturnType<typeof fetchBaseQuery>,
|
| 418 |
+
* SelectedResult
|
| 419 |
+
* > &
|
| 420 |
+
* SubscriptionOptions,
|
| 421 |
+
* ) =>
|
| 422 |
+
* useGetPostsQuery(undefined, {
|
| 423 |
+
* // Insert default options here
|
| 424 |
+
*
|
| 425 |
+
* refetchOnMountOrArgChange: true,
|
| 426 |
+
* refetchOnFocus: true,
|
| 427 |
+
* ...overrideOptions,
|
| 428 |
+
* })
|
| 429 |
+
* ```
|
| 430 |
+
*
|
| 431 |
+
* @template ResultType - The type of the result `data` returned by the query.
|
| 432 |
+
* @template QueryArg - The type of the argument passed into the query.
|
| 433 |
+
* @template BaseQuery - The type of the base query function being used.
|
| 434 |
+
* @template SelectedResult - The type of the selected result returned by the __`selectFromResult`__ function.
|
| 435 |
+
*
|
| 436 |
+
* @since 2.2.8
|
| 437 |
+
* @public
|
| 438 |
+
*/
|
| 439 |
+
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>;
|
| 440 |
+
type UseQueryStateResult<_ extends QueryDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R>;
|
| 441 |
+
/**
|
| 442 |
+
* Helper type to manually type the result
|
| 443 |
+
* of the `useQueryState` hook in userland code.
|
| 444 |
+
*/
|
| 445 |
+
type TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TSHelpersNoInfer<R>;
|
| 446 |
+
type UseQueryStateBaseResult<D extends QueryDefinition<any, any, any, any>> = QuerySubState<D> & {
|
| 447 |
+
/**
|
| 448 |
+
* Where `data` tries to hold data as much as possible, also re-using
|
| 449 |
+
* data from the last arguments passed into the hook, this property
|
| 450 |
+
* will always contain the received data from the query, for the current query arguments.
|
| 451 |
+
*/
|
| 452 |
+
currentData?: ResultTypeFrom<D>;
|
| 453 |
+
/**
|
| 454 |
+
* Query has not started yet.
|
| 455 |
+
*/
|
| 456 |
+
isUninitialized: false;
|
| 457 |
+
/**
|
| 458 |
+
* Query is currently loading for the first time. No data yet.
|
| 459 |
+
*/
|
| 460 |
+
isLoading: false;
|
| 461 |
+
/**
|
| 462 |
+
* Query is currently fetching, but might have data from an earlier request.
|
| 463 |
+
*/
|
| 464 |
+
isFetching: false;
|
| 465 |
+
/**
|
| 466 |
+
* Query has data from a successful load.
|
| 467 |
+
*/
|
| 468 |
+
isSuccess: false;
|
| 469 |
+
/**
|
| 470 |
+
* Query is currently in "error" state.
|
| 471 |
+
*/
|
| 472 |
+
isError: false;
|
| 473 |
+
};
|
| 474 |
+
type UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseQueryStateBaseResult<D>, {
|
| 475 |
+
status: QueryStatus.uninitialized;
|
| 476 |
+
}>, {
|
| 477 |
+
isUninitialized: true;
|
| 478 |
+
}> | TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
| 479 |
+
isLoading: true;
|
| 480 |
+
isFetching: boolean;
|
| 481 |
+
data: undefined;
|
| 482 |
+
} | ({
|
| 483 |
+
isSuccess: true;
|
| 484 |
+
isFetching: true;
|
| 485 |
+
error: undefined;
|
| 486 |
+
} & Required<Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
|
| 487 |
+
isSuccess: true;
|
| 488 |
+
isFetching: false;
|
| 489 |
+
error: undefined;
|
| 490 |
+
} & Required<Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
|
| 491 |
+
isError: true;
|
| 492 |
+
} & Required<Pick<UseQueryStateBaseResult<D>, 'error'>>)>> & {
|
| 493 |
+
/**
|
| 494 |
+
* @deprecated Included for completeness, but discouraged.
|
| 495 |
+
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
| 496 |
+
* and `isUninitialized` flags instead
|
| 497 |
+
*/
|
| 498 |
+
status: QueryStatus;
|
| 499 |
+
};
|
| 500 |
+
type LazyInfiniteQueryTrigger<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
| 501 |
+
/**
|
| 502 |
+
* Triggers a lazy query.
|
| 503 |
+
*
|
| 504 |
+
* By default, this will start a new request even if there is already a value in the cache.
|
| 505 |
+
* 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`.
|
| 506 |
+
*
|
| 507 |
+
* @remarks
|
| 508 |
+
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
| 509 |
+
*
|
| 510 |
+
* @example
|
| 511 |
+
* ```ts
|
| 512 |
+
* // codeblock-meta title="Using .unwrap with async await"
|
| 513 |
+
* try {
|
| 514 |
+
* const payload = await getUserById(1).unwrap();
|
| 515 |
+
* console.log('fulfilled', payload)
|
| 516 |
+
* } catch (error) {
|
| 517 |
+
* console.error('rejected', error);
|
| 518 |
+
* }
|
| 519 |
+
* ```
|
| 520 |
+
*/
|
| 521 |
+
(arg: QueryArgFrom<D>, direction: InfiniteQueryDirection): InfiniteQueryActionCreatorResult<D>;
|
| 522 |
+
};
|
| 523 |
+
type TypedLazyInfiniteQueryTrigger<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = LazyInfiniteQueryTrigger<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 524 |
+
type UseInfiniteQuerySubscriptionOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>> = SubscriptionOptions & {
|
| 525 |
+
/**
|
| 526 |
+
* Prevents a query from automatically running.
|
| 527 |
+
*
|
| 528 |
+
* @remarks
|
| 529 |
+
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
| 530 |
+
*
|
| 531 |
+
* - **If the query has cached data:**
|
| 532 |
+
* * 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
|
| 533 |
+
* * The query will have a status of `uninitialized`
|
| 534 |
+
* * If `skip: false` is set after the initial load, the cached result will be used
|
| 535 |
+
* - **If the query does not have cached data:**
|
| 536 |
+
* * The query will have a status of `uninitialized`
|
| 537 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 538 |
+
* * The query will not automatically fetch on mount
|
| 539 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 540 |
+
*
|
| 541 |
+
* @example
|
| 542 |
+
* ```tsx
|
| 543 |
+
* // codeblock-meta no-transpile title="Skip example"
|
| 544 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 545 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 546 |
+
* skip,
|
| 547 |
+
* });
|
| 548 |
+
*
|
| 549 |
+
* return (
|
| 550 |
+
* <div>
|
| 551 |
+
* {name} - {status}
|
| 552 |
+
* </div>
|
| 553 |
+
* );
|
| 554 |
+
* };
|
| 555 |
+
* ```
|
| 556 |
+
*/
|
| 557 |
+
skip?: boolean;
|
| 558 |
+
/**
|
| 559 |
+
* 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.
|
| 560 |
+
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
| 561 |
+
* - `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.
|
| 562 |
+
* - `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.
|
| 563 |
+
*
|
| 564 |
+
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
| 565 |
+
*/
|
| 566 |
+
refetchOnMountOrArgChange?: boolean | number;
|
| 567 |
+
initialPageParam?: PageParamFrom<D>;
|
| 568 |
+
};
|
| 569 |
+
type TypedUseInfiniteQuerySubscription<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscription<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 570 |
+
type UseInfiniteQuerySubscriptionResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = Pick<InfiniteQueryActionCreatorResult<D>, 'refetch'> & {
|
| 571 |
+
trigger: LazyInfiniteQueryTrigger<D>;
|
| 572 |
+
fetchNextPage: () => InfiniteQueryActionCreatorResult<D>;
|
| 573 |
+
fetchPreviousPage: () => InfiniteQueryActionCreatorResult<D>;
|
| 574 |
+
};
|
| 575 |
+
/**
|
| 576 |
+
* Helper type to manually type the result
|
| 577 |
+
* of the `useQuerySubscription` hook in userland code.
|
| 578 |
+
*/
|
| 579 |
+
type TypedUseInfiniteQuerySubscriptionResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscriptionResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 580 |
+
type InfiniteQueryStateSelector<R extends Record<string, any>, D extends InfiniteQueryDefinition<any, any, any, any, any>> = (state: UseInfiniteQueryStateDefaultResult<D>) => R;
|
| 581 |
+
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>>;
|
| 582 |
+
/**
|
| 583 |
+
* 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.
|
| 584 |
+
*
|
| 585 |
+
* 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.
|
| 586 |
+
*
|
| 587 |
+
* 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.
|
| 588 |
+
*
|
| 589 |
+
* This hook combines the functionality of both [`useInfiniteQueryState`](#useinfinitequerystate) and [`useInfiniteQuerySubscription`](#useinfinitequerysubscription) together, and is intended to be used in the majority of situations.
|
| 590 |
+
*
|
| 591 |
+
* As with normal query hooks, `skipToken` is a valid argument that will skip the query from executing.
|
| 592 |
+
*
|
| 593 |
+
* 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.
|
| 594 |
+
*
|
| 595 |
+
* 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.
|
| 596 |
+
*
|
| 597 |
+
*
|
| 598 |
+
* #### Features
|
| 599 |
+
*
|
| 600 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 601 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 602 |
+
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
| 603 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 604 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 605 |
+
* - Re-renders as the request status changes and data becomes available
|
| 606 |
+
*/
|
| 607 |
+
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'>;
|
| 608 |
+
type TypedUseInfiniteQuery<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuery<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 609 |
+
/**
|
| 610 |
+
* 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.
|
| 611 |
+
*
|
| 612 |
+
* Note that this hook does not trigger fetching new data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQuerySubscription`](#useinfinitequerysubscription).
|
| 613 |
+
*
|
| 614 |
+
* #### Features
|
| 615 |
+
*
|
| 616 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 617 |
+
* - Re-renders as the request status changes and data becomes available
|
| 618 |
+
*/
|
| 619 |
+
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>;
|
| 620 |
+
type TypedUseInfiniteQueryState<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQueryState<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 621 |
+
/**
|
| 622 |
+
* 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.
|
| 623 |
+
*
|
| 624 |
+
* 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.
|
| 625 |
+
*
|
| 626 |
+
* Note that this hook does not return a request status or cached data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQueryState`](#useinfinitequerystate).
|
| 627 |
+
*
|
| 628 |
+
* #### Features
|
| 629 |
+
*
|
| 630 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 631 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 632 |
+
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
| 633 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 634 |
+
*/
|
| 635 |
+
type UseInfiniteQuerySubscription<D extends InfiniteQueryDefinition<any, any, any, any, any>> = (arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D>) => UseInfiniteQuerySubscriptionResult<D>;
|
| 636 |
+
type UseInfiniteQueryHookResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = UseInfiniteQueryStateResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'refetch'>;
|
| 637 |
+
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>;
|
| 638 |
+
type UseInfiniteQueryStateOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>, R extends Record<string, any>> = {
|
| 639 |
+
/**
|
| 640 |
+
* Prevents a query from automatically running.
|
| 641 |
+
*
|
| 642 |
+
* @remarks
|
| 643 |
+
* When skip is true:
|
| 644 |
+
*
|
| 645 |
+
* - **If the query has cached data:**
|
| 646 |
+
* * 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
|
| 647 |
+
* * The query will have a status of `uninitialized`
|
| 648 |
+
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
| 649 |
+
* - **If the query does not have cached data:**
|
| 650 |
+
* * The query will have a status of `uninitialized`
|
| 651 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 652 |
+
* * The query will not automatically fetch on mount
|
| 653 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 654 |
+
*
|
| 655 |
+
* @example
|
| 656 |
+
* ```ts
|
| 657 |
+
* // codeblock-meta title="Skip example"
|
| 658 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 659 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 660 |
+
* skip,
|
| 661 |
+
* });
|
| 662 |
+
*
|
| 663 |
+
* return (
|
| 664 |
+
* <div>
|
| 665 |
+
* {name} - {status}
|
| 666 |
+
* </div>
|
| 667 |
+
* );
|
| 668 |
+
* };
|
| 669 |
+
* ```
|
| 670 |
+
*/
|
| 671 |
+
skip?: boolean;
|
| 672 |
+
/**
|
| 673 |
+
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
| 674 |
+
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
| 675 |
+
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
| 676 |
+
* Note that this should always return an object (not a primitive), as RTKQ adds fields to the return value.
|
| 677 |
+
*
|
| 678 |
+
* @example
|
| 679 |
+
* ```ts
|
| 680 |
+
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
| 681 |
+
* function PostsList() {
|
| 682 |
+
* const { data: posts } = api.useGetPostsQuery();
|
| 683 |
+
*
|
| 684 |
+
* return (
|
| 685 |
+
* <ul>
|
| 686 |
+
* {posts?.data?.map((post) => (
|
| 687 |
+
* <PostById key={post.id} id={post.id} />
|
| 688 |
+
* ))}
|
| 689 |
+
* </ul>
|
| 690 |
+
* );
|
| 691 |
+
* }
|
| 692 |
+
*
|
| 693 |
+
* function PostById({ id }: { id: number }) {
|
| 694 |
+
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
| 695 |
+
* const { post } = api.useGetPostsQuery(undefined, {
|
| 696 |
+
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
| 697 |
+
* });
|
| 698 |
+
*
|
| 699 |
+
* return <li>{post?.name}</li>;
|
| 700 |
+
* }
|
| 701 |
+
* ```
|
| 702 |
+
*/
|
| 703 |
+
selectFromResult?: InfiniteQueryStateSelector<R, D>;
|
| 704 |
+
};
|
| 705 |
+
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>;
|
| 706 |
+
type UseInfiniteQueryStateResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = TSHelpersNoInfer<R>;
|
| 707 |
+
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>;
|
| 708 |
+
type UseInfiniteQueryStateBaseResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = InfiniteQuerySubState<D> & {
|
| 709 |
+
/**
|
| 710 |
+
* Where `data` tries to hold data as much as possible, also re-using
|
| 711 |
+
* data from the last arguments passed into the hook, this property
|
| 712 |
+
* will always contain the received data from the query, for the current query arguments.
|
| 713 |
+
*/
|
| 714 |
+
currentData?: InfiniteData<ResultTypeFrom<D>, PageParamFrom<D>>;
|
| 715 |
+
/**
|
| 716 |
+
* Query has not started yet.
|
| 717 |
+
*/
|
| 718 |
+
isUninitialized: false;
|
| 719 |
+
/**
|
| 720 |
+
* Query is currently loading for the first time. No data yet.
|
| 721 |
+
*/
|
| 722 |
+
isLoading: false;
|
| 723 |
+
/**
|
| 724 |
+
* Query is currently fetching, but might have data from an earlier request.
|
| 725 |
+
*/
|
| 726 |
+
isFetching: false;
|
| 727 |
+
/**
|
| 728 |
+
* Query has data from a successful load.
|
| 729 |
+
*/
|
| 730 |
+
isSuccess: false;
|
| 731 |
+
/**
|
| 732 |
+
* Query is currently in "error" state.
|
| 733 |
+
*/
|
| 734 |
+
isError: false;
|
| 735 |
+
hasNextPage: false;
|
| 736 |
+
hasPreviousPage: false;
|
| 737 |
+
isFetchingNextPage: false;
|
| 738 |
+
isFetchingPreviousPage: false;
|
| 739 |
+
};
|
| 740 |
+
type UseInfiniteQueryStateDefaultResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseInfiniteQueryStateBaseResult<D>, {
|
| 741 |
+
status: QueryStatus.uninitialized;
|
| 742 |
+
}>, {
|
| 743 |
+
isUninitialized: true;
|
| 744 |
+
}> | TSHelpersOverride<UseInfiniteQueryStateBaseResult<D>, {
|
| 745 |
+
isLoading: true;
|
| 746 |
+
isFetching: boolean;
|
| 747 |
+
data: undefined;
|
| 748 |
+
} | ({
|
| 749 |
+
isSuccess: true;
|
| 750 |
+
isFetching: true;
|
| 751 |
+
error: undefined;
|
| 752 |
+
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
|
| 753 |
+
isSuccess: true;
|
| 754 |
+
isFetching: false;
|
| 755 |
+
error: undefined;
|
| 756 |
+
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
|
| 757 |
+
isError: true;
|
| 758 |
+
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'error'>>)>> & {
|
| 759 |
+
/**
|
| 760 |
+
* @deprecated Included for completeness, but discouraged.
|
| 761 |
+
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
| 762 |
+
* and `isUninitialized` flags instead
|
| 763 |
+
*/
|
| 764 |
+
status: QueryStatus;
|
| 765 |
+
};
|
| 766 |
+
type MutationStateSelector<R extends Record<string, any>, D extends MutationDefinition<any, any, any, any>> = (state: MutationResultSelectorResult<D>) => R;
|
| 767 |
+
type UseMutationStateOptions<D extends MutationDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
| 768 |
+
selectFromResult?: MutationStateSelector<R, D>;
|
| 769 |
+
fixedCacheKey?: string;
|
| 770 |
+
};
|
| 771 |
+
type UseMutationStateResult<D extends MutationDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R> & {
|
| 772 |
+
originalArgs?: QueryArgFrom<D>;
|
| 773 |
+
/**
|
| 774 |
+
* Resets the hook state to its initial `uninitialized` state.
|
| 775 |
+
* This will also remove the last result from the cache.
|
| 776 |
+
*/
|
| 777 |
+
reset: () => void;
|
| 778 |
+
};
|
| 779 |
+
/**
|
| 780 |
+
* Helper type to manually type the result
|
| 781 |
+
* of the `useMutation` hook in userland code.
|
| 782 |
+
*/
|
| 783 |
+
type TypedUseMutationResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = MutationResultSelectorResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseMutationStateResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
| 784 |
+
/**
|
| 785 |
+
* 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.
|
| 786 |
+
*
|
| 787 |
+
* #### Features
|
| 788 |
+
*
|
| 789 |
+
* - Manual control over firing a request to alter data on the server or possibly invalidate the cache
|
| 790 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 791 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 792 |
+
* - Re-renders as the request status changes and data becomes available
|
| 793 |
+
*/
|
| 794 |
+
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>];
|
| 795 |
+
type TypedUseMutation<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseMutation<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 796 |
+
type MutationTrigger<D extends MutationDefinition<any, any, any, any>> = {
|
| 797 |
+
/**
|
| 798 |
+
* Triggers the mutation and returns a Promise.
|
| 799 |
+
* @remarks
|
| 800 |
+
* If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
|
| 801 |
+
*
|
| 802 |
+
* @example
|
| 803 |
+
* ```ts
|
| 804 |
+
* // codeblock-meta title="Using .unwrap with async await"
|
| 805 |
+
* try {
|
| 806 |
+
* const payload = await addPost({ id: 1, name: 'Example' }).unwrap();
|
| 807 |
+
* console.log('fulfilled', payload)
|
| 808 |
+
* } catch (error) {
|
| 809 |
+
* console.error('rejected', error);
|
| 810 |
+
* }
|
| 811 |
+
* ```
|
| 812 |
+
*/
|
| 813 |
+
(arg: QueryArgFrom<D>): MutationActionCreatorResult<D>;
|
| 814 |
+
};
|
| 815 |
+
type TypedMutationTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = MutationTrigger<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 816 |
+
|
| 817 |
+
type QueryHookNames<Definitions extends EndpointDefinitions> = {
|
| 818 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 819 |
+
type: DefinitionType.query;
|
| 820 |
+
} ? `use${Capitalize<K & string>}Query` : never]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
| 821 |
+
};
|
| 822 |
+
type LazyQueryHookNames<Definitions extends EndpointDefinitions> = {
|
| 823 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 824 |
+
type: DefinitionType.query;
|
| 825 |
+
} ? `useLazy${Capitalize<K & string>}Query` : never]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
| 826 |
+
};
|
| 827 |
+
type InfiniteQueryHookNames<Definitions extends EndpointDefinitions> = {
|
| 828 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 829 |
+
type: DefinitionType.infinitequery;
|
| 830 |
+
} ? `use${Capitalize<K & string>}InfiniteQuery` : never]: UseInfiniteQuery<Extract<Definitions[K], InfiniteQueryDefinition<any, any, any, any, any>>>;
|
| 831 |
+
};
|
| 832 |
+
type MutationHookNames<Definitions extends EndpointDefinitions> = {
|
| 833 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 834 |
+
type: DefinitionType.mutation;
|
| 835 |
+
} ? `use${Capitalize<K & string>}Mutation` : never]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
|
| 836 |
+
};
|
| 837 |
+
type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = QueryHookNames<Definitions> & LazyQueryHookNames<Definitions> & InfiniteQueryHookNames<Definitions> & MutationHookNames<Definitions>;
|
| 838 |
+
|
| 839 |
+
export declare const reactHooksModuleName: unique symbol;
|
| 840 |
+
type ReactHooksModule = typeof reactHooksModuleName;
|
| 841 |
+
declare module '@reduxjs/toolkit/query' {
|
| 842 |
+
interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
|
| 843 |
+
[reactHooksModuleName]: {
|
| 844 |
+
/**
|
| 845 |
+
* Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.
|
| 846 |
+
*/
|
| 847 |
+
endpoints: {
|
| 848 |
+
[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;
|
| 849 |
+
};
|
| 850 |
+
/**
|
| 851 |
+
* A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.
|
| 852 |
+
*/
|
| 853 |
+
usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
|
| 854 |
+
} & HooksWithUniqueNames<Definitions>;
|
| 855 |
+
}
|
| 856 |
+
}
|
| 857 |
+
type RR = typeof react_redux;
|
| 858 |
+
interface ReactHooksModuleOptions {
|
| 859 |
+
/**
|
| 860 |
+
* The hooks from React Redux to be used
|
| 861 |
+
*/
|
| 862 |
+
hooks?: {
|
| 863 |
+
/**
|
| 864 |
+
* The version of the `useDispatch` hook to be used
|
| 865 |
+
*/
|
| 866 |
+
useDispatch: RR['useDispatch'];
|
| 867 |
+
/**
|
| 868 |
+
* The version of the `useSelector` hook to be used
|
| 869 |
+
*/
|
| 870 |
+
useSelector: RR['useSelector'];
|
| 871 |
+
/**
|
| 872 |
+
* The version of the `useStore` hook to be used
|
| 873 |
+
*/
|
| 874 |
+
useStore: RR['useStore'];
|
| 875 |
+
};
|
| 876 |
+
/**
|
| 877 |
+
* The version of the `batchedUpdates` function to be used
|
| 878 |
+
*/
|
| 879 |
+
batch?: RR['batch'];
|
| 880 |
+
/**
|
| 881 |
+
* Enables performing asynchronous tasks immediately within a render.
|
| 882 |
+
*
|
| 883 |
+
* @example
|
| 884 |
+
*
|
| 885 |
+
* ```ts
|
| 886 |
+
* import {
|
| 887 |
+
* buildCreateApi,
|
| 888 |
+
* coreModule,
|
| 889 |
+
* reactHooksModule
|
| 890 |
+
* } from '@reduxjs/toolkit/query/react'
|
| 891 |
+
*
|
| 892 |
+
* const createApi = buildCreateApi(
|
| 893 |
+
* coreModule(),
|
| 894 |
+
* reactHooksModule({ unstable__sideEffectsInRender: true })
|
| 895 |
+
* )
|
| 896 |
+
* ```
|
| 897 |
+
*/
|
| 898 |
+
unstable__sideEffectsInRender?: boolean;
|
| 899 |
+
/**
|
| 900 |
+
* A selector creator (usually from `reselect`, or matching the same signature)
|
| 901 |
+
*/
|
| 902 |
+
createSelector?: typeof createSelector;
|
| 903 |
+
}
|
| 904 |
+
/**
|
| 905 |
+
* Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.
|
| 906 |
+
*
|
| 907 |
+
* @example
|
| 908 |
+
* ```ts
|
| 909 |
+
* const MyContext = React.createContext<ReactReduxContextValue | null>(null);
|
| 910 |
+
* const customCreateApi = buildCreateApi(
|
| 911 |
+
* coreModule(),
|
| 912 |
+
* reactHooksModule({
|
| 913 |
+
* hooks: {
|
| 914 |
+
* useDispatch: createDispatchHook(MyContext),
|
| 915 |
+
* useSelector: createSelectorHook(MyContext),
|
| 916 |
+
* useStore: createStoreHook(MyContext)
|
| 917 |
+
* }
|
| 918 |
+
* })
|
| 919 |
+
* );
|
| 920 |
+
* ```
|
| 921 |
+
*
|
| 922 |
+
* @returns A module for use with `buildCreateApi`
|
| 923 |
+
*/
|
| 924 |
+
declare const reactHooksModule: ({ batch, hooks, createSelector, unstable__sideEffectsInRender, ...rest }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
|
| 925 |
+
|
| 926 |
+
/**
|
| 927 |
+
* Can be used as a `Provider` if you **do not already have a Redux store**.
|
| 928 |
+
*
|
| 929 |
+
* @example
|
| 930 |
+
* ```tsx
|
| 931 |
+
* // codeblock-meta no-transpile title="Basic usage - wrap your App with ApiProvider"
|
| 932 |
+
* import * as React from 'react';
|
| 933 |
+
* import { ApiProvider } from '@reduxjs/toolkit/query/react';
|
| 934 |
+
* import { Pokemon } from './features/Pokemon';
|
| 935 |
+
*
|
| 936 |
+
* function App() {
|
| 937 |
+
* return (
|
| 938 |
+
* <ApiProvider api={api}>
|
| 939 |
+
* <Pokemon />
|
| 940 |
+
* </ApiProvider>
|
| 941 |
+
* );
|
| 942 |
+
* }
|
| 943 |
+
* ```
|
| 944 |
+
*
|
| 945 |
+
* @remarks
|
| 946 |
+
* Using this together with an existing redux store, both will
|
| 947 |
+
* conflict with each other - please use the traditional redux setup
|
| 948 |
+
* in that case.
|
| 949 |
+
*/
|
| 950 |
+
declare function ApiProvider(props: {
|
| 951 |
+
children: any;
|
| 952 |
+
api: Api<any, {}, any, any>;
|
| 953 |
+
setupListeners?: Parameters<typeof setupListeners>[1] | false;
|
| 954 |
+
context?: Context<ReactReduxContextValue | null>;
|
| 955 |
+
}): React.JSX.Element;
|
| 956 |
+
|
| 957 |
+
declare const createApi: _reduxjs_toolkit_query.CreateApi<typeof _reduxjs_toolkit_query.coreModuleName | typeof reactHooksModuleName>;
|
| 958 |
+
|
| 959 |
+
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 };
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts
ADDED
|
@@ -0,0 +1,959 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
| 2 |
+
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';
|
| 3 |
+
export * from '@reduxjs/toolkit/query';
|
| 4 |
+
import * as react_redux from 'react-redux';
|
| 5 |
+
import { ReactReduxContextValue } from 'react-redux';
|
| 6 |
+
import { createSelector } from 'reselect';
|
| 7 |
+
import * as React from 'react';
|
| 8 |
+
import { Context } from 'react';
|
| 9 |
+
|
| 10 |
+
type InfiniteData<DataType, PageParam> = {
|
| 11 |
+
pages: Array<DataType>;
|
| 12 |
+
pageParams: Array<PageParam>;
|
| 13 |
+
};
|
| 14 |
+
type InfiniteQueryDirection = 'forward' | 'backward';
|
| 15 |
+
|
| 16 |
+
export declare const UNINITIALIZED_VALUE: unique symbol;
|
| 17 |
+
type UninitializedValue = typeof UNINITIALIZED_VALUE;
|
| 18 |
+
|
| 19 |
+
type QueryHooks<Definition extends QueryDefinition<any, any, any, any, any>> = {
|
| 20 |
+
useQuery: UseQuery<Definition>;
|
| 21 |
+
useLazyQuery: UseLazyQuery<Definition>;
|
| 22 |
+
useQuerySubscription: UseQuerySubscription<Definition>;
|
| 23 |
+
useLazyQuerySubscription: UseLazyQuerySubscription<Definition>;
|
| 24 |
+
useQueryState: UseQueryState<Definition>;
|
| 25 |
+
};
|
| 26 |
+
type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
| 27 |
+
useInfiniteQuery: UseInfiniteQuery<Definition>;
|
| 28 |
+
useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;
|
| 29 |
+
useInfiniteQueryState: UseInfiniteQueryState<Definition>;
|
| 30 |
+
};
|
| 31 |
+
type MutationHooks<Definition extends MutationDefinition<any, any, any, any, any>> = {
|
| 32 |
+
useMutation: UseMutation<Definition>;
|
| 33 |
+
};
|
| 34 |
+
/**
|
| 35 |
+
* 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.
|
| 36 |
+
*
|
| 37 |
+
* 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.
|
| 38 |
+
*
|
| 39 |
+
* This hook combines the functionality of both [`useQueryState`](#usequerystate) and [`useQuerySubscription`](#usequerysubscription) together, and is intended to be used in the majority of situations.
|
| 40 |
+
*
|
| 41 |
+
* #### Features
|
| 42 |
+
*
|
| 43 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 44 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 45 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 46 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 47 |
+
* - Re-renders as the request status changes and data becomes available
|
| 48 |
+
*/
|
| 49 |
+
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>;
|
| 50 |
+
type TypedUseQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 51 |
+
type UseQueryHookResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & UseQuerySubscriptionResult<D>;
|
| 52 |
+
/**
|
| 53 |
+
* Helper type to manually type the result
|
| 54 |
+
* of the `useQuery` hook in userland code.
|
| 55 |
+
*/
|
| 56 |
+
type TypedUseQueryHookResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery, R> & TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery>;
|
| 57 |
+
type UseQuerySubscriptionOptions = SubscriptionOptions & {
|
| 58 |
+
/**
|
| 59 |
+
* Prevents a query from automatically running.
|
| 60 |
+
*
|
| 61 |
+
* @remarks
|
| 62 |
+
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
| 63 |
+
*
|
| 64 |
+
* - **If the query has cached data:**
|
| 65 |
+
* * 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
|
| 66 |
+
* * The query will have a status of `uninitialized`
|
| 67 |
+
* * If `skip: false` is set after the initial load, the cached result will be used
|
| 68 |
+
* - **If the query does not have cached data:**
|
| 69 |
+
* * The query will have a status of `uninitialized`
|
| 70 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 71 |
+
* * The query will not automatically fetch on mount
|
| 72 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 73 |
+
*
|
| 74 |
+
* @example
|
| 75 |
+
* ```tsx
|
| 76 |
+
* // codeblock-meta no-transpile title="Skip example"
|
| 77 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 78 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 79 |
+
* skip,
|
| 80 |
+
* });
|
| 81 |
+
*
|
| 82 |
+
* return (
|
| 83 |
+
* <div>
|
| 84 |
+
* {name} - {status}
|
| 85 |
+
* </div>
|
| 86 |
+
* );
|
| 87 |
+
* };
|
| 88 |
+
* ```
|
| 89 |
+
*/
|
| 90 |
+
skip?: boolean;
|
| 91 |
+
/**
|
| 92 |
+
* 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.
|
| 93 |
+
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
| 94 |
+
* - `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.
|
| 95 |
+
* - `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.
|
| 96 |
+
*
|
| 97 |
+
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
| 98 |
+
*/
|
| 99 |
+
refetchOnMountOrArgChange?: boolean | number;
|
| 100 |
+
};
|
| 101 |
+
/**
|
| 102 |
+
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.
|
| 103 |
+
*
|
| 104 |
+
* 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.
|
| 105 |
+
*
|
| 106 |
+
* Note that this hook does not return a request status or cached data. For that use-case, see [`useQuery`](#usequery) or [`useQueryState`](#usequerystate).
|
| 107 |
+
*
|
| 108 |
+
* #### Features
|
| 109 |
+
*
|
| 110 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 111 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 112 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 113 |
+
*/
|
| 114 |
+
type UseQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions) => UseQuerySubscriptionResult<D>;
|
| 115 |
+
type TypedUseQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 116 |
+
type UseQuerySubscriptionResult<D extends QueryDefinition<any, any, any, any>> = Pick<QueryActionCreatorResult<D>, 'refetch'>;
|
| 117 |
+
/**
|
| 118 |
+
* Helper type to manually type the result
|
| 119 |
+
* of the `useQuerySubscription` hook in userland code.
|
| 120 |
+
*/
|
| 121 |
+
type TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscriptionResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 122 |
+
type UseLazyQueryLastPromiseInfo<D extends QueryDefinition<any, any, any, any>> = {
|
| 123 |
+
lastArg: QueryArgFrom<D>;
|
| 124 |
+
};
|
| 125 |
+
/**
|
| 126 |
+
* A React hook similar to [`useQuery`](#usequery), but with manual control over when the data fetching occurs.
|
| 127 |
+
*
|
| 128 |
+
* This hook includes the functionality of [`useLazyQuerySubscription`](#uselazyquerysubscription).
|
| 129 |
+
*
|
| 130 |
+
* #### Features
|
| 131 |
+
*
|
| 132 |
+
* - Manual control over firing a request to retrieve data
|
| 133 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 134 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 135 |
+
* - Re-renders as the request status changes and data becomes available
|
| 136 |
+
* - 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
|
| 137 |
+
*
|
| 138 |
+
* #### Note
|
| 139 |
+
*
|
| 140 |
+
* 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.
|
| 141 |
+
*/
|
| 142 |
+
type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>) => [
|
| 143 |
+
LazyQueryTrigger<D>,
|
| 144 |
+
UseLazyQueryStateResult<D, R>,
|
| 145 |
+
UseLazyQueryLastPromiseInfo<D>
|
| 146 |
+
];
|
| 147 |
+
type TypedUseLazyQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 148 |
+
type UseLazyQueryStateResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & {
|
| 149 |
+
/**
|
| 150 |
+
* Resets the hook state to its initial `uninitialized` state.
|
| 151 |
+
* This will also remove the last result from the cache.
|
| 152 |
+
*/
|
| 153 |
+
reset: () => void;
|
| 154 |
+
};
|
| 155 |
+
/**
|
| 156 |
+
* Helper type to manually type the result
|
| 157 |
+
* of the `useLazyQuery` hook in userland code.
|
| 158 |
+
*/
|
| 159 |
+
type TypedUseLazyQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseLazyQueryStateResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
| 160 |
+
type LazyQueryTrigger<D extends QueryDefinition<any, any, any, any>> = {
|
| 161 |
+
/**
|
| 162 |
+
* Triggers a lazy query.
|
| 163 |
+
*
|
| 164 |
+
* By default, this will start a new request even if there is already a value in the cache.
|
| 165 |
+
* 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`.
|
| 166 |
+
*
|
| 167 |
+
* @remarks
|
| 168 |
+
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
| 169 |
+
*
|
| 170 |
+
* @example
|
| 171 |
+
* ```ts
|
| 172 |
+
* // codeblock-meta title="Using .unwrap with async await"
|
| 173 |
+
* try {
|
| 174 |
+
* const payload = await getUserById(1).unwrap();
|
| 175 |
+
* console.log('fulfilled', payload)
|
| 176 |
+
* } catch (error) {
|
| 177 |
+
* console.error('rejected', error);
|
| 178 |
+
* }
|
| 179 |
+
* ```
|
| 180 |
+
*/
|
| 181 |
+
(arg: QueryArgFrom<D>, preferCacheValue?: boolean): QueryActionCreatorResult<D>;
|
| 182 |
+
};
|
| 183 |
+
type TypedLazyQueryTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = LazyQueryTrigger<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 184 |
+
/**
|
| 185 |
+
* A React hook similar to [`useQuerySubscription`](#usequerysubscription), but with manual control over when the data fetching occurs.
|
| 186 |
+
*
|
| 187 |
+
* Note that this hook does not return a request status or cached data. For that use-case, see [`useLazyQuery`](#uselazyquery).
|
| 188 |
+
*
|
| 189 |
+
* #### Features
|
| 190 |
+
*
|
| 191 |
+
* - Manual control over firing a request to retrieve data
|
| 192 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 193 |
+
* - 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
|
| 194 |
+
*/
|
| 195 |
+
type UseLazyQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (options?: SubscriptionOptions) => readonly [
|
| 196 |
+
LazyQueryTrigger<D>,
|
| 197 |
+
QueryArgFrom<D> | UninitializedValue,
|
| 198 |
+
{
|
| 199 |
+
reset: () => void;
|
| 200 |
+
}
|
| 201 |
+
];
|
| 202 |
+
type TypedUseLazyQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 203 |
+
/**
|
| 204 |
+
* @internal
|
| 205 |
+
*/
|
| 206 |
+
type QueryStateSelector<R extends Record<string, any>, D extends QueryDefinition<any, any, any, any>> = (state: UseQueryStateDefaultResult<D>) => R;
|
| 207 |
+
/**
|
| 208 |
+
* Provides a way to define a strongly-typed version of
|
| 209 |
+
* {@linkcode QueryStateSelector} for use with a specific query.
|
| 210 |
+
* This is useful for scenarios where you want to create a "pre-typed"
|
| 211 |
+
* {@linkcode UseQueryStateOptions.selectFromResult | selectFromResult}
|
| 212 |
+
* function.
|
| 213 |
+
*
|
| 214 |
+
* @example
|
| 215 |
+
* <caption>#### __Create a strongly-typed `selectFromResult` selector function__</caption>
|
| 216 |
+
*
|
| 217 |
+
* ```tsx
|
| 218 |
+
* import type { TypedQueryStateSelector } from '@reduxjs/toolkit/query/react'
|
| 219 |
+
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
| 220 |
+
*
|
| 221 |
+
* type Post = {
|
| 222 |
+
* id: number
|
| 223 |
+
* title: string
|
| 224 |
+
* }
|
| 225 |
+
*
|
| 226 |
+
* type PostsApiResponse = {
|
| 227 |
+
* posts: Post[]
|
| 228 |
+
* total: number
|
| 229 |
+
* skip: number
|
| 230 |
+
* limit: number
|
| 231 |
+
* }
|
| 232 |
+
*
|
| 233 |
+
* type QueryArgument = number | undefined
|
| 234 |
+
*
|
| 235 |
+
* type BaseQueryFunction = ReturnType<typeof fetchBaseQuery>
|
| 236 |
+
*
|
| 237 |
+
* type SelectedResult = Pick<PostsApiResponse, 'posts'>
|
| 238 |
+
*
|
| 239 |
+
* const postsApiSlice = createApi({
|
| 240 |
+
* baseQuery: fetchBaseQuery({ baseUrl: 'https://dummyjson.com/posts' }),
|
| 241 |
+
* reducerPath: 'postsApi',
|
| 242 |
+
* tagTypes: ['Posts'],
|
| 243 |
+
* endpoints: (build) => ({
|
| 244 |
+
* getPosts: build.query<PostsApiResponse, QueryArgument>({
|
| 245 |
+
* query: (limit = 5) => `?limit=${limit}&select=title`,
|
| 246 |
+
* }),
|
| 247 |
+
* }),
|
| 248 |
+
* })
|
| 249 |
+
*
|
| 250 |
+
* const { useGetPostsQuery } = postsApiSlice
|
| 251 |
+
*
|
| 252 |
+
* function PostById({ id }: { id: number }) {
|
| 253 |
+
* const { post } = useGetPostsQuery(undefined, {
|
| 254 |
+
* selectFromResult: (state) => ({
|
| 255 |
+
* post: state.data?.posts.find((post) => post.id === id),
|
| 256 |
+
* }),
|
| 257 |
+
* })
|
| 258 |
+
*
|
| 259 |
+
* return <li>{post?.title}</li>
|
| 260 |
+
* }
|
| 261 |
+
*
|
| 262 |
+
* const EMPTY_ARRAY: Post[] = []
|
| 263 |
+
*
|
| 264 |
+
* const typedSelectFromResult: TypedQueryStateSelector<
|
| 265 |
+
* PostsApiResponse,
|
| 266 |
+
* QueryArgument,
|
| 267 |
+
* BaseQueryFunction,
|
| 268 |
+
* SelectedResult
|
| 269 |
+
* > = (state) => ({ posts: state.data?.posts ?? EMPTY_ARRAY })
|
| 270 |
+
*
|
| 271 |
+
* function PostsList() {
|
| 272 |
+
* const { posts } = useGetPostsQuery(undefined, {
|
| 273 |
+
* selectFromResult: typedSelectFromResult,
|
| 274 |
+
* })
|
| 275 |
+
*
|
| 276 |
+
* return (
|
| 277 |
+
* <div>
|
| 278 |
+
* <ul>
|
| 279 |
+
* {posts.map((post) => (
|
| 280 |
+
* <PostById key={post.id} id={post.id} />
|
| 281 |
+
* ))}
|
| 282 |
+
* </ul>
|
| 283 |
+
* </div>
|
| 284 |
+
* )
|
| 285 |
+
* }
|
| 286 |
+
* ```
|
| 287 |
+
*
|
| 288 |
+
* @template ResultType - The type of the result `data` returned by the query.
|
| 289 |
+
* @template QueryArgumentType - The type of the argument passed into the query.
|
| 290 |
+
* @template BaseQueryFunctionType - The type of the base query function being used.
|
| 291 |
+
* @template SelectedResultType - The type of the selected result returned by the __`selectFromResult`__ function.
|
| 292 |
+
*
|
| 293 |
+
* @since 2.3.0
|
| 294 |
+
* @public
|
| 295 |
+
*/
|
| 296 |
+
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>>;
|
| 297 |
+
/**
|
| 298 |
+
* 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.
|
| 299 |
+
*
|
| 300 |
+
* Note that this hook does not trigger fetching new data. For that use-case, see [`useQuery`](#usequery) or [`useQuerySubscription`](#usequerysubscription).
|
| 301 |
+
*
|
| 302 |
+
* #### Features
|
| 303 |
+
*
|
| 304 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 305 |
+
* - Re-renders as the request status changes and data becomes available
|
| 306 |
+
*/
|
| 307 |
+
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>;
|
| 308 |
+
type TypedUseQueryState<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQueryState<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 309 |
+
/**
|
| 310 |
+
* @internal
|
| 311 |
+
*/
|
| 312 |
+
type UseQueryStateOptions<D extends QueryDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
| 313 |
+
/**
|
| 314 |
+
* Prevents a query from automatically running.
|
| 315 |
+
*
|
| 316 |
+
* @remarks
|
| 317 |
+
* When skip is true:
|
| 318 |
+
*
|
| 319 |
+
* - **If the query has cached data:**
|
| 320 |
+
* * 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
|
| 321 |
+
* * The query will have a status of `uninitialized`
|
| 322 |
+
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
| 323 |
+
* - **If the query does not have cached data:**
|
| 324 |
+
* * The query will have a status of `uninitialized`
|
| 325 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 326 |
+
* * The query will not automatically fetch on mount
|
| 327 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 328 |
+
*
|
| 329 |
+
* @example
|
| 330 |
+
* ```ts
|
| 331 |
+
* // codeblock-meta title="Skip example"
|
| 332 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 333 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 334 |
+
* skip,
|
| 335 |
+
* });
|
| 336 |
+
*
|
| 337 |
+
* return (
|
| 338 |
+
* <div>
|
| 339 |
+
* {name} - {status}
|
| 340 |
+
* </div>
|
| 341 |
+
* );
|
| 342 |
+
* };
|
| 343 |
+
* ```
|
| 344 |
+
*/
|
| 345 |
+
skip?: boolean;
|
| 346 |
+
/**
|
| 347 |
+
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
| 348 |
+
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
| 349 |
+
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
| 350 |
+
*
|
| 351 |
+
* @example
|
| 352 |
+
* ```ts
|
| 353 |
+
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
| 354 |
+
* function PostsList() {
|
| 355 |
+
* const { data: posts } = api.useGetPostsQuery();
|
| 356 |
+
*
|
| 357 |
+
* return (
|
| 358 |
+
* <ul>
|
| 359 |
+
* {posts?.data?.map((post) => (
|
| 360 |
+
* <PostById key={post.id} id={post.id} />
|
| 361 |
+
* ))}
|
| 362 |
+
* </ul>
|
| 363 |
+
* );
|
| 364 |
+
* }
|
| 365 |
+
*
|
| 366 |
+
* function PostById({ id }: { id: number }) {
|
| 367 |
+
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
| 368 |
+
* const { post } = api.useGetPostsQuery(undefined, {
|
| 369 |
+
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
| 370 |
+
* });
|
| 371 |
+
*
|
| 372 |
+
* return <li>{post?.name}</li>;
|
| 373 |
+
* }
|
| 374 |
+
* ```
|
| 375 |
+
*/
|
| 376 |
+
selectFromResult?: QueryStateSelector<R, D>;
|
| 377 |
+
};
|
| 378 |
+
/**
|
| 379 |
+
* Provides a way to define a "pre-typed" version of
|
| 380 |
+
* {@linkcode UseQueryStateOptions} with specific options for a given query.
|
| 381 |
+
* This is particularly useful for setting default query behaviors such as
|
| 382 |
+
* refetching strategies, which can be overridden as needed.
|
| 383 |
+
*
|
| 384 |
+
* @example
|
| 385 |
+
* <caption>#### __Create a `useQuery` hook with default options__</caption>
|
| 386 |
+
*
|
| 387 |
+
* ```ts
|
| 388 |
+
* import type {
|
| 389 |
+
* SubscriptionOptions,
|
| 390 |
+
* TypedUseQueryStateOptions,
|
| 391 |
+
* } from '@reduxjs/toolkit/query/react'
|
| 392 |
+
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
| 393 |
+
*
|
| 394 |
+
* type Post = {
|
| 395 |
+
* id: number
|
| 396 |
+
* name: string
|
| 397 |
+
* }
|
| 398 |
+
*
|
| 399 |
+
* const api = createApi({
|
| 400 |
+
* baseQuery: fetchBaseQuery({ baseUrl: '/' }),
|
| 401 |
+
* tagTypes: ['Post'],
|
| 402 |
+
* endpoints: (build) => ({
|
| 403 |
+
* getPosts: build.query<Post[], void>({
|
| 404 |
+
* query: () => 'posts',
|
| 405 |
+
* }),
|
| 406 |
+
* }),
|
| 407 |
+
* })
|
| 408 |
+
*
|
| 409 |
+
* const { useGetPostsQuery } = api
|
| 410 |
+
*
|
| 411 |
+
* export const useGetPostsQueryWithDefaults = <
|
| 412 |
+
* SelectedResult extends Record<string, any>,
|
| 413 |
+
* >(
|
| 414 |
+
* overrideOptions: TypedUseQueryStateOptions<
|
| 415 |
+
* Post[],
|
| 416 |
+
* void,
|
| 417 |
+
* ReturnType<typeof fetchBaseQuery>,
|
| 418 |
+
* SelectedResult
|
| 419 |
+
* > &
|
| 420 |
+
* SubscriptionOptions,
|
| 421 |
+
* ) =>
|
| 422 |
+
* useGetPostsQuery(undefined, {
|
| 423 |
+
* // Insert default options here
|
| 424 |
+
*
|
| 425 |
+
* refetchOnMountOrArgChange: true,
|
| 426 |
+
* refetchOnFocus: true,
|
| 427 |
+
* ...overrideOptions,
|
| 428 |
+
* })
|
| 429 |
+
* ```
|
| 430 |
+
*
|
| 431 |
+
* @template ResultType - The type of the result `data` returned by the query.
|
| 432 |
+
* @template QueryArg - The type of the argument passed into the query.
|
| 433 |
+
* @template BaseQuery - The type of the base query function being used.
|
| 434 |
+
* @template SelectedResult - The type of the selected result returned by the __`selectFromResult`__ function.
|
| 435 |
+
*
|
| 436 |
+
* @since 2.2.8
|
| 437 |
+
* @public
|
| 438 |
+
*/
|
| 439 |
+
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>;
|
| 440 |
+
type UseQueryStateResult<_ extends QueryDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R>;
|
| 441 |
+
/**
|
| 442 |
+
* Helper type to manually type the result
|
| 443 |
+
* of the `useQueryState` hook in userland code.
|
| 444 |
+
*/
|
| 445 |
+
type TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TSHelpersNoInfer<R>;
|
| 446 |
+
type UseQueryStateBaseResult<D extends QueryDefinition<any, any, any, any>> = QuerySubState<D> & {
|
| 447 |
+
/**
|
| 448 |
+
* Where `data` tries to hold data as much as possible, also re-using
|
| 449 |
+
* data from the last arguments passed into the hook, this property
|
| 450 |
+
* will always contain the received data from the query, for the current query arguments.
|
| 451 |
+
*/
|
| 452 |
+
currentData?: ResultTypeFrom<D>;
|
| 453 |
+
/**
|
| 454 |
+
* Query has not started yet.
|
| 455 |
+
*/
|
| 456 |
+
isUninitialized: false;
|
| 457 |
+
/**
|
| 458 |
+
* Query is currently loading for the first time. No data yet.
|
| 459 |
+
*/
|
| 460 |
+
isLoading: false;
|
| 461 |
+
/**
|
| 462 |
+
* Query is currently fetching, but might have data from an earlier request.
|
| 463 |
+
*/
|
| 464 |
+
isFetching: false;
|
| 465 |
+
/**
|
| 466 |
+
* Query has data from a successful load.
|
| 467 |
+
*/
|
| 468 |
+
isSuccess: false;
|
| 469 |
+
/**
|
| 470 |
+
* Query is currently in "error" state.
|
| 471 |
+
*/
|
| 472 |
+
isError: false;
|
| 473 |
+
};
|
| 474 |
+
type UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseQueryStateBaseResult<D>, {
|
| 475 |
+
status: QueryStatus.uninitialized;
|
| 476 |
+
}>, {
|
| 477 |
+
isUninitialized: true;
|
| 478 |
+
}> | TSHelpersOverride<UseQueryStateBaseResult<D>, {
|
| 479 |
+
isLoading: true;
|
| 480 |
+
isFetching: boolean;
|
| 481 |
+
data: undefined;
|
| 482 |
+
} | ({
|
| 483 |
+
isSuccess: true;
|
| 484 |
+
isFetching: true;
|
| 485 |
+
error: undefined;
|
| 486 |
+
} & Required<Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
|
| 487 |
+
isSuccess: true;
|
| 488 |
+
isFetching: false;
|
| 489 |
+
error: undefined;
|
| 490 |
+
} & Required<Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
|
| 491 |
+
isError: true;
|
| 492 |
+
} & Required<Pick<UseQueryStateBaseResult<D>, 'error'>>)>> & {
|
| 493 |
+
/**
|
| 494 |
+
* @deprecated Included for completeness, but discouraged.
|
| 495 |
+
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
| 496 |
+
* and `isUninitialized` flags instead
|
| 497 |
+
*/
|
| 498 |
+
status: QueryStatus;
|
| 499 |
+
};
|
| 500 |
+
type LazyInfiniteQueryTrigger<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
|
| 501 |
+
/**
|
| 502 |
+
* Triggers a lazy query.
|
| 503 |
+
*
|
| 504 |
+
* By default, this will start a new request even if there is already a value in the cache.
|
| 505 |
+
* 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`.
|
| 506 |
+
*
|
| 507 |
+
* @remarks
|
| 508 |
+
* If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
|
| 509 |
+
*
|
| 510 |
+
* @example
|
| 511 |
+
* ```ts
|
| 512 |
+
* // codeblock-meta title="Using .unwrap with async await"
|
| 513 |
+
* try {
|
| 514 |
+
* const payload = await getUserById(1).unwrap();
|
| 515 |
+
* console.log('fulfilled', payload)
|
| 516 |
+
* } catch (error) {
|
| 517 |
+
* console.error('rejected', error);
|
| 518 |
+
* }
|
| 519 |
+
* ```
|
| 520 |
+
*/
|
| 521 |
+
(arg: QueryArgFrom<D>, direction: InfiniteQueryDirection): InfiniteQueryActionCreatorResult<D>;
|
| 522 |
+
};
|
| 523 |
+
type TypedLazyInfiniteQueryTrigger<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = LazyInfiniteQueryTrigger<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 524 |
+
type UseInfiniteQuerySubscriptionOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>> = SubscriptionOptions & {
|
| 525 |
+
/**
|
| 526 |
+
* Prevents a query from automatically running.
|
| 527 |
+
*
|
| 528 |
+
* @remarks
|
| 529 |
+
* When `skip` is true (or `skipToken` is passed in as `arg`):
|
| 530 |
+
*
|
| 531 |
+
* - **If the query has cached data:**
|
| 532 |
+
* * 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
|
| 533 |
+
* * The query will have a status of `uninitialized`
|
| 534 |
+
* * If `skip: false` is set after the initial load, the cached result will be used
|
| 535 |
+
* - **If the query does not have cached data:**
|
| 536 |
+
* * The query will have a status of `uninitialized`
|
| 537 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 538 |
+
* * The query will not automatically fetch on mount
|
| 539 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 540 |
+
*
|
| 541 |
+
* @example
|
| 542 |
+
* ```tsx
|
| 543 |
+
* // codeblock-meta no-transpile title="Skip example"
|
| 544 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 545 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 546 |
+
* skip,
|
| 547 |
+
* });
|
| 548 |
+
*
|
| 549 |
+
* return (
|
| 550 |
+
* <div>
|
| 551 |
+
* {name} - {status}
|
| 552 |
+
* </div>
|
| 553 |
+
* );
|
| 554 |
+
* };
|
| 555 |
+
* ```
|
| 556 |
+
*/
|
| 557 |
+
skip?: boolean;
|
| 558 |
+
/**
|
| 559 |
+
* 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.
|
| 560 |
+
* - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
|
| 561 |
+
* - `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.
|
| 562 |
+
* - `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.
|
| 563 |
+
*
|
| 564 |
+
* If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
|
| 565 |
+
*/
|
| 566 |
+
refetchOnMountOrArgChange?: boolean | number;
|
| 567 |
+
initialPageParam?: PageParamFrom<D>;
|
| 568 |
+
};
|
| 569 |
+
type TypedUseInfiniteQuerySubscription<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscription<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 570 |
+
type UseInfiniteQuerySubscriptionResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = Pick<InfiniteQueryActionCreatorResult<D>, 'refetch'> & {
|
| 571 |
+
trigger: LazyInfiniteQueryTrigger<D>;
|
| 572 |
+
fetchNextPage: () => InfiniteQueryActionCreatorResult<D>;
|
| 573 |
+
fetchPreviousPage: () => InfiniteQueryActionCreatorResult<D>;
|
| 574 |
+
};
|
| 575 |
+
/**
|
| 576 |
+
* Helper type to manually type the result
|
| 577 |
+
* of the `useQuerySubscription` hook in userland code.
|
| 578 |
+
*/
|
| 579 |
+
type TypedUseInfiniteQuerySubscriptionResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscriptionResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 580 |
+
type InfiniteQueryStateSelector<R extends Record<string, any>, D extends InfiniteQueryDefinition<any, any, any, any, any>> = (state: UseInfiniteQueryStateDefaultResult<D>) => R;
|
| 581 |
+
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>>;
|
| 582 |
+
/**
|
| 583 |
+
* 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.
|
| 584 |
+
*
|
| 585 |
+
* 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.
|
| 586 |
+
*
|
| 587 |
+
* 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.
|
| 588 |
+
*
|
| 589 |
+
* This hook combines the functionality of both [`useInfiniteQueryState`](#useinfinitequerystate) and [`useInfiniteQuerySubscription`](#useinfinitequerysubscription) together, and is intended to be used in the majority of situations.
|
| 590 |
+
*
|
| 591 |
+
* As with normal query hooks, `skipToken` is a valid argument that will skip the query from executing.
|
| 592 |
+
*
|
| 593 |
+
* 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.
|
| 594 |
+
*
|
| 595 |
+
* 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.
|
| 596 |
+
*
|
| 597 |
+
*
|
| 598 |
+
* #### Features
|
| 599 |
+
*
|
| 600 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 601 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 602 |
+
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
| 603 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 604 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 605 |
+
* - Re-renders as the request status changes and data becomes available
|
| 606 |
+
*/
|
| 607 |
+
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'>;
|
| 608 |
+
type TypedUseInfiniteQuery<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuery<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 609 |
+
/**
|
| 610 |
+
* 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.
|
| 611 |
+
*
|
| 612 |
+
* Note that this hook does not trigger fetching new data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQuerySubscription`](#useinfinitequerysubscription).
|
| 613 |
+
*
|
| 614 |
+
* #### Features
|
| 615 |
+
*
|
| 616 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 617 |
+
* - Re-renders as the request status changes and data becomes available
|
| 618 |
+
*/
|
| 619 |
+
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>;
|
| 620 |
+
type TypedUseInfiniteQueryState<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQueryState<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
|
| 621 |
+
/**
|
| 622 |
+
* 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.
|
| 623 |
+
*
|
| 624 |
+
* 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.
|
| 625 |
+
*
|
| 626 |
+
* Note that this hook does not return a request status or cached data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQueryState`](#useinfinitequerystate).
|
| 627 |
+
*
|
| 628 |
+
* #### Features
|
| 629 |
+
*
|
| 630 |
+
* - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
|
| 631 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 632 |
+
* - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
|
| 633 |
+
* - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
|
| 634 |
+
*/
|
| 635 |
+
type UseInfiniteQuerySubscription<D extends InfiniteQueryDefinition<any, any, any, any, any>> = (arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D>) => UseInfiniteQuerySubscriptionResult<D>;
|
| 636 |
+
type UseInfiniteQueryHookResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = UseInfiniteQueryStateResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'refetch'>;
|
| 637 |
+
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>;
|
| 638 |
+
type UseInfiniteQueryStateOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>, R extends Record<string, any>> = {
|
| 639 |
+
/**
|
| 640 |
+
* Prevents a query from automatically running.
|
| 641 |
+
*
|
| 642 |
+
* @remarks
|
| 643 |
+
* When skip is true:
|
| 644 |
+
*
|
| 645 |
+
* - **If the query has cached data:**
|
| 646 |
+
* * 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
|
| 647 |
+
* * The query will have a status of `uninitialized`
|
| 648 |
+
* * If `skip: false` is set after skipping the initial load, the cached result will be used
|
| 649 |
+
* - **If the query does not have cached data:**
|
| 650 |
+
* * The query will have a status of `uninitialized`
|
| 651 |
+
* * The query will not exist in the state when viewed with the dev tools
|
| 652 |
+
* * The query will not automatically fetch on mount
|
| 653 |
+
* * The query will not automatically run when additional components with the same query are added that do run
|
| 654 |
+
*
|
| 655 |
+
* @example
|
| 656 |
+
* ```ts
|
| 657 |
+
* // codeblock-meta title="Skip example"
|
| 658 |
+
* const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
|
| 659 |
+
* const { data, error, status } = useGetPokemonByNameQuery(name, {
|
| 660 |
+
* skip,
|
| 661 |
+
* });
|
| 662 |
+
*
|
| 663 |
+
* return (
|
| 664 |
+
* <div>
|
| 665 |
+
* {name} - {status}
|
| 666 |
+
* </div>
|
| 667 |
+
* );
|
| 668 |
+
* };
|
| 669 |
+
* ```
|
| 670 |
+
*/
|
| 671 |
+
skip?: boolean;
|
| 672 |
+
/**
|
| 673 |
+
* `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
|
| 674 |
+
* When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
|
| 675 |
+
* If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
|
| 676 |
+
* Note that this should always return an object (not a primitive), as RTKQ adds fields to the return value.
|
| 677 |
+
*
|
| 678 |
+
* @example
|
| 679 |
+
* ```ts
|
| 680 |
+
* // codeblock-meta title="Using selectFromResult to extract a single result"
|
| 681 |
+
* function PostsList() {
|
| 682 |
+
* const { data: posts } = api.useGetPostsQuery();
|
| 683 |
+
*
|
| 684 |
+
* return (
|
| 685 |
+
* <ul>
|
| 686 |
+
* {posts?.data?.map((post) => (
|
| 687 |
+
* <PostById key={post.id} id={post.id} />
|
| 688 |
+
* ))}
|
| 689 |
+
* </ul>
|
| 690 |
+
* );
|
| 691 |
+
* }
|
| 692 |
+
*
|
| 693 |
+
* function PostById({ id }: { id: number }) {
|
| 694 |
+
* // Will select the post with the given id, and will only rerender if the given posts data changes
|
| 695 |
+
* const { post } = api.useGetPostsQuery(undefined, {
|
| 696 |
+
* selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
|
| 697 |
+
* });
|
| 698 |
+
*
|
| 699 |
+
* return <li>{post?.name}</li>;
|
| 700 |
+
* }
|
| 701 |
+
* ```
|
| 702 |
+
*/
|
| 703 |
+
selectFromResult?: InfiniteQueryStateSelector<R, D>;
|
| 704 |
+
};
|
| 705 |
+
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>;
|
| 706 |
+
type UseInfiniteQueryStateResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = TSHelpersNoInfer<R>;
|
| 707 |
+
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>;
|
| 708 |
+
type UseInfiniteQueryStateBaseResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = InfiniteQuerySubState<D> & {
|
| 709 |
+
/**
|
| 710 |
+
* Where `data` tries to hold data as much as possible, also re-using
|
| 711 |
+
* data from the last arguments passed into the hook, this property
|
| 712 |
+
* will always contain the received data from the query, for the current query arguments.
|
| 713 |
+
*/
|
| 714 |
+
currentData?: InfiniteData<ResultTypeFrom<D>, PageParamFrom<D>>;
|
| 715 |
+
/**
|
| 716 |
+
* Query has not started yet.
|
| 717 |
+
*/
|
| 718 |
+
isUninitialized: false;
|
| 719 |
+
/**
|
| 720 |
+
* Query is currently loading for the first time. No data yet.
|
| 721 |
+
*/
|
| 722 |
+
isLoading: false;
|
| 723 |
+
/**
|
| 724 |
+
* Query is currently fetching, but might have data from an earlier request.
|
| 725 |
+
*/
|
| 726 |
+
isFetching: false;
|
| 727 |
+
/**
|
| 728 |
+
* Query has data from a successful load.
|
| 729 |
+
*/
|
| 730 |
+
isSuccess: false;
|
| 731 |
+
/**
|
| 732 |
+
* Query is currently in "error" state.
|
| 733 |
+
*/
|
| 734 |
+
isError: false;
|
| 735 |
+
hasNextPage: false;
|
| 736 |
+
hasPreviousPage: false;
|
| 737 |
+
isFetchingNextPage: false;
|
| 738 |
+
isFetchingPreviousPage: false;
|
| 739 |
+
};
|
| 740 |
+
type UseInfiniteQueryStateDefaultResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseInfiniteQueryStateBaseResult<D>, {
|
| 741 |
+
status: QueryStatus.uninitialized;
|
| 742 |
+
}>, {
|
| 743 |
+
isUninitialized: true;
|
| 744 |
+
}> | TSHelpersOverride<UseInfiniteQueryStateBaseResult<D>, {
|
| 745 |
+
isLoading: true;
|
| 746 |
+
isFetching: boolean;
|
| 747 |
+
data: undefined;
|
| 748 |
+
} | ({
|
| 749 |
+
isSuccess: true;
|
| 750 |
+
isFetching: true;
|
| 751 |
+
error: undefined;
|
| 752 |
+
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
|
| 753 |
+
isSuccess: true;
|
| 754 |
+
isFetching: false;
|
| 755 |
+
error: undefined;
|
| 756 |
+
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
|
| 757 |
+
isError: true;
|
| 758 |
+
} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'error'>>)>> & {
|
| 759 |
+
/**
|
| 760 |
+
* @deprecated Included for completeness, but discouraged.
|
| 761 |
+
* Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
|
| 762 |
+
* and `isUninitialized` flags instead
|
| 763 |
+
*/
|
| 764 |
+
status: QueryStatus;
|
| 765 |
+
};
|
| 766 |
+
type MutationStateSelector<R extends Record<string, any>, D extends MutationDefinition<any, any, any, any>> = (state: MutationResultSelectorResult<D>) => R;
|
| 767 |
+
type UseMutationStateOptions<D extends MutationDefinition<any, any, any, any>, R extends Record<string, any>> = {
|
| 768 |
+
selectFromResult?: MutationStateSelector<R, D>;
|
| 769 |
+
fixedCacheKey?: string;
|
| 770 |
+
};
|
| 771 |
+
type UseMutationStateResult<D extends MutationDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R> & {
|
| 772 |
+
originalArgs?: QueryArgFrom<D>;
|
| 773 |
+
/**
|
| 774 |
+
* Resets the hook state to its initial `uninitialized` state.
|
| 775 |
+
* This will also remove the last result from the cache.
|
| 776 |
+
*/
|
| 777 |
+
reset: () => void;
|
| 778 |
+
};
|
| 779 |
+
/**
|
| 780 |
+
* Helper type to manually type the result
|
| 781 |
+
* of the `useMutation` hook in userland code.
|
| 782 |
+
*/
|
| 783 |
+
type TypedUseMutationResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = MutationResultSelectorResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseMutationStateResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
|
| 784 |
+
/**
|
| 785 |
+
* 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.
|
| 786 |
+
*
|
| 787 |
+
* #### Features
|
| 788 |
+
*
|
| 789 |
+
* - Manual control over firing a request to alter data on the server or possibly invalidate the cache
|
| 790 |
+
* - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
|
| 791 |
+
* - Returns the latest request status and cached data from the Redux store
|
| 792 |
+
* - Re-renders as the request status changes and data becomes available
|
| 793 |
+
*/
|
| 794 |
+
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>];
|
| 795 |
+
type TypedUseMutation<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseMutation<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 796 |
+
type MutationTrigger<D extends MutationDefinition<any, any, any, any>> = {
|
| 797 |
+
/**
|
| 798 |
+
* Triggers the mutation and returns a Promise.
|
| 799 |
+
* @remarks
|
| 800 |
+
* If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
|
| 801 |
+
*
|
| 802 |
+
* @example
|
| 803 |
+
* ```ts
|
| 804 |
+
* // codeblock-meta title="Using .unwrap with async await"
|
| 805 |
+
* try {
|
| 806 |
+
* const payload = await addPost({ id: 1, name: 'Example' }).unwrap();
|
| 807 |
+
* console.log('fulfilled', payload)
|
| 808 |
+
* } catch (error) {
|
| 809 |
+
* console.error('rejected', error);
|
| 810 |
+
* }
|
| 811 |
+
* ```
|
| 812 |
+
*/
|
| 813 |
+
(arg: QueryArgFrom<D>): MutationActionCreatorResult<D>;
|
| 814 |
+
};
|
| 815 |
+
type TypedMutationTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = MutationTrigger<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
|
| 816 |
+
|
| 817 |
+
type QueryHookNames<Definitions extends EndpointDefinitions> = {
|
| 818 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 819 |
+
type: DefinitionType.query;
|
| 820 |
+
} ? `use${Capitalize<K & string>}Query` : never]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
| 821 |
+
};
|
| 822 |
+
type LazyQueryHookNames<Definitions extends EndpointDefinitions> = {
|
| 823 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 824 |
+
type: DefinitionType.query;
|
| 825 |
+
} ? `useLazy${Capitalize<K & string>}Query` : never]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
|
| 826 |
+
};
|
| 827 |
+
type InfiniteQueryHookNames<Definitions extends EndpointDefinitions> = {
|
| 828 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 829 |
+
type: DefinitionType.infinitequery;
|
| 830 |
+
} ? `use${Capitalize<K & string>}InfiniteQuery` : never]: UseInfiniteQuery<Extract<Definitions[K], InfiniteQueryDefinition<any, any, any, any, any>>>;
|
| 831 |
+
};
|
| 832 |
+
type MutationHookNames<Definitions extends EndpointDefinitions> = {
|
| 833 |
+
[K in keyof Definitions as Definitions[K] extends {
|
| 834 |
+
type: DefinitionType.mutation;
|
| 835 |
+
} ? `use${Capitalize<K & string>}Mutation` : never]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
|
| 836 |
+
};
|
| 837 |
+
type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = QueryHookNames<Definitions> & LazyQueryHookNames<Definitions> & InfiniteQueryHookNames<Definitions> & MutationHookNames<Definitions>;
|
| 838 |
+
|
| 839 |
+
export declare const reactHooksModuleName: unique symbol;
|
| 840 |
+
type ReactHooksModule = typeof reactHooksModuleName;
|
| 841 |
+
declare module '@reduxjs/toolkit/query' {
|
| 842 |
+
interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
|
| 843 |
+
[reactHooksModuleName]: {
|
| 844 |
+
/**
|
| 845 |
+
* Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.
|
| 846 |
+
*/
|
| 847 |
+
endpoints: {
|
| 848 |
+
[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;
|
| 849 |
+
};
|
| 850 |
+
/**
|
| 851 |
+
* A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.
|
| 852 |
+
*/
|
| 853 |
+
usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
|
| 854 |
+
} & HooksWithUniqueNames<Definitions>;
|
| 855 |
+
}
|
| 856 |
+
}
|
| 857 |
+
type RR = typeof react_redux;
|
| 858 |
+
interface ReactHooksModuleOptions {
|
| 859 |
+
/**
|
| 860 |
+
* The hooks from React Redux to be used
|
| 861 |
+
*/
|
| 862 |
+
hooks?: {
|
| 863 |
+
/**
|
| 864 |
+
* The version of the `useDispatch` hook to be used
|
| 865 |
+
*/
|
| 866 |
+
useDispatch: RR['useDispatch'];
|
| 867 |
+
/**
|
| 868 |
+
* The version of the `useSelector` hook to be used
|
| 869 |
+
*/
|
| 870 |
+
useSelector: RR['useSelector'];
|
| 871 |
+
/**
|
| 872 |
+
* The version of the `useStore` hook to be used
|
| 873 |
+
*/
|
| 874 |
+
useStore: RR['useStore'];
|
| 875 |
+
};
|
| 876 |
+
/**
|
| 877 |
+
* The version of the `batchedUpdates` function to be used
|
| 878 |
+
*/
|
| 879 |
+
batch?: RR['batch'];
|
| 880 |
+
/**
|
| 881 |
+
* Enables performing asynchronous tasks immediately within a render.
|
| 882 |
+
*
|
| 883 |
+
* @example
|
| 884 |
+
*
|
| 885 |
+
* ```ts
|
| 886 |
+
* import {
|
| 887 |
+
* buildCreateApi,
|
| 888 |
+
* coreModule,
|
| 889 |
+
* reactHooksModule
|
| 890 |
+
* } from '@reduxjs/toolkit/query/react'
|
| 891 |
+
*
|
| 892 |
+
* const createApi = buildCreateApi(
|
| 893 |
+
* coreModule(),
|
| 894 |
+
* reactHooksModule({ unstable__sideEffectsInRender: true })
|
| 895 |
+
* )
|
| 896 |
+
* ```
|
| 897 |
+
*/
|
| 898 |
+
unstable__sideEffectsInRender?: boolean;
|
| 899 |
+
/**
|
| 900 |
+
* A selector creator (usually from `reselect`, or matching the same signature)
|
| 901 |
+
*/
|
| 902 |
+
createSelector?: typeof createSelector;
|
| 903 |
+
}
|
| 904 |
+
/**
|
| 905 |
+
* Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.
|
| 906 |
+
*
|
| 907 |
+
* @example
|
| 908 |
+
* ```ts
|
| 909 |
+
* const MyContext = React.createContext<ReactReduxContextValue | null>(null);
|
| 910 |
+
* const customCreateApi = buildCreateApi(
|
| 911 |
+
* coreModule(),
|
| 912 |
+
* reactHooksModule({
|
| 913 |
+
* hooks: {
|
| 914 |
+
* useDispatch: createDispatchHook(MyContext),
|
| 915 |
+
* useSelector: createSelectorHook(MyContext),
|
| 916 |
+
* useStore: createStoreHook(MyContext)
|
| 917 |
+
* }
|
| 918 |
+
* })
|
| 919 |
+
* );
|
| 920 |
+
* ```
|
| 921 |
+
*
|
| 922 |
+
* @returns A module for use with `buildCreateApi`
|
| 923 |
+
*/
|
| 924 |
+
declare const reactHooksModule: ({ batch, hooks, createSelector, unstable__sideEffectsInRender, ...rest }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
|
| 925 |
+
|
| 926 |
+
/**
|
| 927 |
+
* Can be used as a `Provider` if you **do not already have a Redux store**.
|
| 928 |
+
*
|
| 929 |
+
* @example
|
| 930 |
+
* ```tsx
|
| 931 |
+
* // codeblock-meta no-transpile title="Basic usage - wrap your App with ApiProvider"
|
| 932 |
+
* import * as React from 'react';
|
| 933 |
+
* import { ApiProvider } from '@reduxjs/toolkit/query/react';
|
| 934 |
+
* import { Pokemon } from './features/Pokemon';
|
| 935 |
+
*
|
| 936 |
+
* function App() {
|
| 937 |
+
* return (
|
| 938 |
+
* <ApiProvider api={api}>
|
| 939 |
+
* <Pokemon />
|
| 940 |
+
* </ApiProvider>
|
| 941 |
+
* );
|
| 942 |
+
* }
|
| 943 |
+
* ```
|
| 944 |
+
*
|
| 945 |
+
* @remarks
|
| 946 |
+
* Using this together with an existing redux store, both will
|
| 947 |
+
* conflict with each other - please use the traditional redux setup
|
| 948 |
+
* in that case.
|
| 949 |
+
*/
|
| 950 |
+
declare function ApiProvider(props: {
|
| 951 |
+
children: any;
|
| 952 |
+
api: Api<any, {}, any, any>;
|
| 953 |
+
setupListeners?: Parameters<typeof setupListeners>[1] | false;
|
| 954 |
+
context?: Context<ReactReduxContextValue | null>;
|
| 955 |
+
}): React.JSX.Element;
|
| 956 |
+
|
| 957 |
+
declare const createApi: _reduxjs_toolkit_query.CreateApi<typeof _reduxjs_toolkit_query.coreModuleName | typeof reactHooksModuleName>;
|
| 958 |
+
|
| 959 |
+
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 };
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import{buildCreateApi as qe,coreModule as Ke}from"@reduxjs/toolkit/query";import"@reduxjs/toolkit";import{batch as be,useDispatch as Ee,useSelector as ke,useStore as Me}from"react-redux";import{createSelector as Oe}from"reselect";function q(e){return e.replace(e[0],e[0].toUpperCase())}function ie(e){return e.type==="query"}function se(e){return e.type==="mutation"}function _(e){return e.type==="infinitequery"}function L(e,...c){return Object.assign(e,...c)}import{formatProdErrorMessage as xe}from"@reduxjs/toolkit";import{defaultSerializeQueryArgs as ue,QueryStatus as me,skipToken as b}from"@reduxjs/toolkit/query";import{useCallback as F,useDebugValue as ee,useEffect as N,useLayoutEffect as Se,useMemo as A,useRef as C,useState as ye}from"react";import{shallowEqual as te}from"react-redux";var K=Symbol();import{useEffect as le,useRef as ge,useMemo as Re}from"react";function j(e,c,x,l){let h=Re(()=>({queryArgs:e,serialized:typeof e=="object"?c({queryArgs:e,endpointDefinition:x,endpointName:l}):e}),[e,c,x,l]),g=ge(h);return le(()=>{g.current.serialized!==h.serialized&&(g.current=h)},[h]),g.current.serialized===h.serialized?g.current.queryArgs:e}import{useEffect as Te,useRef as De}from"react";import{shallowEqual as ae}from"react-redux";function V(e){let c=De(e);return Te(()=>{ae(c.current,e)||(c.current=e)},[e]),ae(c.current,e)?c.current:e}var Ae=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Be=Ae(),Pe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",he=Pe(),Ie=()=>Be||he?Se:N,Ue=Ie(),oe=e=>e.isUninitialized?{...e,isUninitialized:!1,isFetching:!0,isLoading:e.data===void 0,status:me.pending}:e;function ne(e,...c){let x={};return c.forEach(l=>{x[l]=e[l]}),x}var re=["data","status","isLoading","isSuccess","isError","error"];function pe({api:e,moduleOptions:{batch:c,hooks:{useDispatch:x,useSelector:l,useStore:h},unstable__sideEffectsInRender:g,createSelector:w},serializeQueryArgs:I,context:B}){let E=g?t=>t():N;return{buildQueryHooks:H,buildInfiniteQueryHooks:Y,buildMutationHook:J,usePrefetch:Z};function $(t,i,p){if(i?.endpointName&&t.isUninitialized){let{endpointName:a}=i,y=B.endpointDefinitions[a];p!==b&&I({queryArgs:i.originalArgs,endpointDefinition:y,endpointName:a})===I({queryArgs:p,endpointDefinition:y,endpointName:a})&&(i=void 0)}let u=t.isSuccess?t.data:i?.data;u===void 0&&(u=t.data);let s=u!==void 0,n=t.isLoading,r=(!i||i.isLoading||i.isUninitialized)&&!s&&n,o=t.isSuccess||s&&(n&&!i?.isError||t.isUninitialized);return{...t,data:u,currentData:t.data,isFetching:n,isLoading:r,isSuccess:o}}function G(t,i,p){if(i?.endpointName&&t.isUninitialized){let{endpointName:a}=i,y=B.endpointDefinitions[a];p!==b&&I({queryArgs:i.originalArgs,endpointDefinition:y,endpointName:a})===I({queryArgs:p,endpointDefinition:y,endpointName:a})&&(i=void 0)}let u=t.isSuccess?t.data:i?.data;u===void 0&&(u=t.data);let s=u!==void 0,n=t.isLoading,r=(!i||i.isLoading||i.isUninitialized)&&!s&&n,o=t.isSuccess||n&&s;return{...t,data:u,currentData:t.data,isFetching:n,isLoading:r,isSuccess:o}}function Z(t,i){let p=x(),u=V(i);return F((s,n)=>p(e.util.prefetch(t,s,{...u,...n})),[t,p,u])}function m(t,i,{refetchOnReconnect:p,refetchOnFocus:u,refetchOnMountOrArgChange:s,skip:n=!1,pollingInterval:r=0,skipPollingIfUnfocused:o=!1,...a}={}){let{initiate:y}=e.endpoints[t],Q=x(),S=C(void 0);if(!S.current){let O=Q(e.internalActions.internal_getRTKQSubscriptions());S.current=O}let f=j(n?b:i,ue,B.endpointDefinitions[t],t),d=V({refetchOnReconnect:p,refetchOnFocus:u,pollingInterval:r,skipPollingIfUnfocused:o}),R=a.initialPageParam,T=V(R),D=C(void 0),{queryCacheKey:U,requestId:M}=D.current||{},z=!1;U&&M&&(z=S.current.isRequestSubscribed(U,M));let X=!z&&D.current!==void 0;return E(()=>{X&&(D.current=void 0)},[X]),E(()=>{let O=D.current;if(f===b){O?.unsubscribe(),D.current=void 0;return}let de=D.current?.subscriptionOptions;if(!O||O.arg!==f){O?.unsubscribe();let ce=Q(y(f,{subscriptionOptions:d,forceRefetch:s,..._(B.endpointDefinitions[t])?{initialPageParam:T}:{}}));D.current=ce}else d!==de&&O.updateSubscriptionOptions(d)},[Q,y,s,f,d,X,T,t]),[D,Q,y,d]}function v(t,i){return(u,{skip:s=!1,selectFromResult:n}={})=>{let{select:r}=e.endpoints[t],o=j(s?b:u,I,B.endpointDefinitions[t],t),a=C(void 0),y=A(()=>w([r(o),(R,T)=>T,R=>o],i,{memoizeOptions:{resultEqualityCheck:te}}),[r,o]),Q=A(()=>n?w([y],n,{devModeChecks:{identityFunctionCheck:"never"}}):y,[y,n]),S=l(R=>Q(R,a.current),te),f=h(),d=y(f.getState(),a.current);return Ue(()=>{a.current=d},[d]),S}}function P(t){N(()=>()=>{t.current?.unsubscribe?.(),t.current=void 0},[t])}function k(t){if(!t.current)throw new Error(xe(38));return t.current.refetch()}function H(t){let i=(s,n={})=>{let[r]=m(t,s,n);return P(r),A(()=>({refetch:()=>k(r)}),[r])},p=({refetchOnReconnect:s,refetchOnFocus:n,pollingInterval:r=0,skipPollingIfUnfocused:o=!1}={})=>{let{initiate:a}=e.endpoints[t],y=x(),[Q,S]=ye(K),f=C(void 0),d=V({refetchOnReconnect:s,refetchOnFocus:n,pollingInterval:r,skipPollingIfUnfocused:o});E(()=>{let U=f.current?.subscriptionOptions;d!==U&&f.current?.updateSubscriptionOptions(d)},[d]);let R=C(d);E(()=>{R.current=d},[d]);let T=F(function(U,M=!1){let z;return c(()=>{f.current?.unsubscribe(),f.current=z=y(a(U,{subscriptionOptions:R.current,forceRefetch:!M})),S(U)}),z},[y,a]),D=F(()=>{f.current?.queryCacheKey&&y(e.internalActions.removeQueryResult({queryCacheKey:f.current?.queryCacheKey}))},[y]);return N(()=>()=>{f?.current?.unsubscribe()},[]),N(()=>{Q!==K&&!f.current&&T(Q,!0)},[Q,T]),A(()=>[T,Q,{reset:D}],[T,Q,D])},u=v(t,$);return{useQueryState:u,useQuerySubscription:i,useLazyQuerySubscription:p,useLazyQuery(s){let[n,r,{reset:o}]=p(s),a=u(r,{...s,skip:r===K}),y=A(()=>({lastArg:r}),[r]);return A(()=>[n,{...a,reset:o},y],[n,a,o,y])},useQuery(s,n){let r=i(s,n),o=u(s,{selectFromResult:s===b||n?.skip?void 0:oe,...n}),a=ne(o,...re);return ee(a),A(()=>({...o,...r}),[o,r])}}}function Y(t){let i=(u,s={})=>{let[n,r,o,a]=m(t,u,s),y=C(a);E(()=>{y.current=a},[a]);let Q=F(function(d,R){let T;return c(()=>{n.current?.unsubscribe(),n.current=T=r(o(d,{subscriptionOptions:y.current,direction:R}))}),T},[n,r,o]);P(n);let S=j(s.skip?b:u,ue,B.endpointDefinitions[t],t),f=F(()=>k(n),[n]);return A(()=>({trigger:Q,refetch:f,fetchNextPage:()=>Q(S,"forward"),fetchPreviousPage:()=>Q(S,"backward")}),[f,Q,S])},p=v(t,G);return{useInfiniteQueryState:p,useInfiniteQuerySubscription:i,useInfiniteQuery(u,s){let{refetch:n,fetchNextPage:r,fetchPreviousPage:o}=i(u,s),a=p(u,{selectFromResult:u===b||s?.skip?void 0:oe,...s}),y=ne(a,...re,"hasNextPage","hasPreviousPage");return ee(y),A(()=>({...a,fetchNextPage:r,fetchPreviousPage:o,refetch:n}),[a,r,o,n])}}}function J(t){return({selectFromResult:i,fixedCacheKey:p}={})=>{let{select:u,initiate:s}=e.endpoints[t],n=x(),[r,o]=ye();N(()=>()=>{r?.arg.fixedCacheKey||r?.reset()},[r]);let a=F(function(U){let M=n(s(U,{fixedCacheKey:p}));return o(M),M},[n,s,p]),{requestId:y}=r||{},Q=A(()=>u({fixedCacheKey:p,requestId:r?.requestId}),[p,r,u]),S=A(()=>i?w([Q],i):Q,[i,Q]),f=l(S,te),d=p==null?r?.arg.originalArgs:void 0,R=F(()=>{c(()=>{r&&o(void 0),p&&n(e.internalActions.removeMutationResult({requestId:y,fixedCacheKey:p}))})},[n,p,r,y]),T=ne(f,...re,"endpointName");ee(T);let D=A(()=>({...f,originalArgs:d,reset:R}),[f,d,R]);return A(()=>[a,D],[a,D])}}}var fe=Symbol(),Qe=({batch:e=be,hooks:c={useDispatch:Ee,useSelector:ke,useStore:Me},createSelector:x=Oe,unstable__sideEffectsInRender:l=!1,...h}={})=>({name:fe,init(g,{serializeQueryArgs:w},I){let B=g,{buildQueryHooks:E,buildInfiniteQueryHooks:$,buildMutationHook:G,usePrefetch:Z}=pe({api:g,moduleOptions:{batch:e,hooks:c,unstable__sideEffectsInRender:l,createSelector:x},serializeQueryArgs:w,context:I});return L(B,{usePrefetch:Z}),L(I,{batch:e}),{injectEndpoint(m,v){if(ie(v)){let{useQuery:P,useLazyQuery:k,useLazyQuerySubscription:H,useQueryState:Y,useQuerySubscription:J}=E(m);L(B.endpoints[m],{useQuery:P,useLazyQuery:k,useLazyQuerySubscription:H,useQueryState:Y,useQuerySubscription:J}),g[`use${q(m)}Query`]=P,g[`useLazy${q(m)}Query`]=k}if(se(v)){let P=G(m);L(B.endpoints[m],{useMutation:P}),g[`use${q(m)}Mutation`]=P}else if(_(v)){let{useInfiniteQuery:P,useInfiniteQuerySubscription:k,useInfiniteQueryState:H}=$(m);L(B.endpoints[m],{useInfiniteQuery:P,useInfiniteQuerySubscription:k,useInfiniteQueryState:H}),g[`use${q(m)}InfiniteQuery`]=P}}}}});export*from"@reduxjs/toolkit/query";import{configureStore as Fe,formatProdErrorMessage as we}from"@reduxjs/toolkit";import{useContext as ve}from"react";import{useEffect as Le}from"react";import*as W from"react";import{Provider as Ce,ReactReduxContext as Ne}from"react-redux";import{setupListeners as He}from"@reduxjs/toolkit/query";function ze(e){let c=e.context||Ne;if(ve(c))throw new Error(we(35));let[l]=W.useState(()=>Fe({reducer:{[e.api.reducerPath]:e.api.reducer},middleware:h=>h().concat(e.api.middleware)}));return Le(()=>e.setupListeners===!1?void 0:He(l.dispatch,e.setupListeners),[e.setupListeners,l.dispatch]),W.createElement(Ce,{store:l,context:c},e.children)}var It=qe(Ke(),Qe());export{ze as ApiProvider,K as UNINITIALIZED_VALUE,It as createApi,Qe as reactHooksModule,fe as reactHooksModuleName};
|
| 2 |
+
//# sourceMappingURL=rtk-query-react.browser.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.browser.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js
ADDED
|
@@ -0,0 +1,753 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var __defProp = Object.defineProperty;
|
| 2 |
+
var __defProps = Object.defineProperties;
|
| 3 |
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
| 4 |
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
| 7 |
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
| 8 |
+
var __spreadValues = (a, b) => {
|
| 9 |
+
for (var prop in b || (b = {}))
|
| 10 |
+
if (__hasOwnProp.call(b, prop))
|
| 11 |
+
__defNormalProp(a, prop, b[prop]);
|
| 12 |
+
if (__getOwnPropSymbols)
|
| 13 |
+
for (var prop of __getOwnPropSymbols(b)) {
|
| 14 |
+
if (__propIsEnum.call(b, prop))
|
| 15 |
+
__defNormalProp(a, prop, b[prop]);
|
| 16 |
+
}
|
| 17 |
+
return a;
|
| 18 |
+
};
|
| 19 |
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
| 20 |
+
var __objRest = (source, exclude) => {
|
| 21 |
+
var target = {};
|
| 22 |
+
for (var prop in source)
|
| 23 |
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
| 24 |
+
target[prop] = source[prop];
|
| 25 |
+
if (source != null && __getOwnPropSymbols)
|
| 26 |
+
for (var prop of __getOwnPropSymbols(source)) {
|
| 27 |
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
| 28 |
+
target[prop] = source[prop];
|
| 29 |
+
}
|
| 30 |
+
return target;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
// src/query/react/index.ts
|
| 34 |
+
import { buildCreateApi, coreModule } from "@reduxjs/toolkit/query";
|
| 35 |
+
|
| 36 |
+
// src/query/react/module.ts
|
| 37 |
+
import { formatProdErrorMessage as _formatProdErrorMessage3 } from "@reduxjs/toolkit";
|
| 38 |
+
import { batch as rrBatch, useDispatch as rrUseDispatch, useSelector as rrUseSelector, useStore as rrUseStore } from "react-redux";
|
| 39 |
+
import { createSelector as _createSelector } from "reselect";
|
| 40 |
+
|
| 41 |
+
// src/query/utils/capitalize.ts
|
| 42 |
+
function capitalize(str) {
|
| 43 |
+
return str.replace(str[0], str[0].toUpperCase());
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// src/query/utils/countObjectKeys.ts
|
| 47 |
+
function countObjectKeys(obj) {
|
| 48 |
+
let count = 0;
|
| 49 |
+
for (const _key in obj) {
|
| 50 |
+
count++;
|
| 51 |
+
}
|
| 52 |
+
return count;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// src/query/endpointDefinitions.ts
|
| 56 |
+
function isQueryDefinition(e) {
|
| 57 |
+
return e.type === "query" /* query */;
|
| 58 |
+
}
|
| 59 |
+
function isMutationDefinition(e) {
|
| 60 |
+
return e.type === "mutation" /* mutation */;
|
| 61 |
+
}
|
| 62 |
+
function isInfiniteQueryDefinition(e) {
|
| 63 |
+
return e.type === "infinitequery" /* infinitequery */;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
// src/query/tsHelpers.ts
|
| 67 |
+
function safeAssign(target, ...args) {
|
| 68 |
+
return Object.assign(target, ...args);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// src/query/react/buildHooks.ts
|
| 72 |
+
import { formatProdErrorMessage as _formatProdErrorMessage, formatProdErrorMessage as _formatProdErrorMessage2 } from "@reduxjs/toolkit";
|
| 73 |
+
import { defaultSerializeQueryArgs, QueryStatus, skipToken } from "@reduxjs/toolkit/query";
|
| 74 |
+
import { useCallback, useDebugValue, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo2, useRef as useRef3, useState } from "react";
|
| 75 |
+
import { shallowEqual as shallowEqual2 } from "react-redux";
|
| 76 |
+
|
| 77 |
+
// src/query/react/constants.ts
|
| 78 |
+
var UNINITIALIZED_VALUE = Symbol();
|
| 79 |
+
|
| 80 |
+
// src/query/react/useSerializedStableValue.ts
|
| 81 |
+
import { useEffect, useRef, useMemo } from "react";
|
| 82 |
+
function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
|
| 83 |
+
const incoming = useMemo(() => ({
|
| 84 |
+
queryArgs,
|
| 85 |
+
serialized: typeof queryArgs == "object" ? serialize({
|
| 86 |
+
queryArgs,
|
| 87 |
+
endpointDefinition,
|
| 88 |
+
endpointName
|
| 89 |
+
}) : queryArgs
|
| 90 |
+
}), [queryArgs, serialize, endpointDefinition, endpointName]);
|
| 91 |
+
const cache = useRef(incoming);
|
| 92 |
+
useEffect(() => {
|
| 93 |
+
if (cache.current.serialized !== incoming.serialized) {
|
| 94 |
+
cache.current = incoming;
|
| 95 |
+
}
|
| 96 |
+
}, [incoming]);
|
| 97 |
+
return cache.current.serialized === incoming.serialized ? cache.current.queryArgs : queryArgs;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
// src/query/react/useShallowStableValue.ts
|
| 101 |
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
| 102 |
+
import { shallowEqual } from "react-redux";
|
| 103 |
+
function useShallowStableValue(value) {
|
| 104 |
+
const cache = useRef2(value);
|
| 105 |
+
useEffect2(() => {
|
| 106 |
+
if (!shallowEqual(cache.current, value)) {
|
| 107 |
+
cache.current = value;
|
| 108 |
+
}
|
| 109 |
+
}, [value]);
|
| 110 |
+
return shallowEqual(cache.current, value) ? cache.current : value;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
// src/query/react/buildHooks.ts
|
| 114 |
+
var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
| 115 |
+
var isDOM = /* @__PURE__ */ canUseDOM();
|
| 116 |
+
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
| 117 |
+
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
| 118 |
+
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? useLayoutEffect : useEffect3;
|
| 119 |
+
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
| 120 |
+
var noPendingQueryStateSelector = (selected) => {
|
| 121 |
+
if (selected.isUninitialized) {
|
| 122 |
+
return __spreadProps(__spreadValues({}, selected), {
|
| 123 |
+
isUninitialized: false,
|
| 124 |
+
isFetching: true,
|
| 125 |
+
isLoading: selected.data !== void 0 ? false : true,
|
| 126 |
+
status: QueryStatus.pending
|
| 127 |
+
});
|
| 128 |
+
}
|
| 129 |
+
return selected;
|
| 130 |
+
};
|
| 131 |
+
function pick(obj, ...keys) {
|
| 132 |
+
const ret = {};
|
| 133 |
+
keys.forEach((key) => {
|
| 134 |
+
ret[key] = obj[key];
|
| 135 |
+
});
|
| 136 |
+
return ret;
|
| 137 |
+
}
|
| 138 |
+
var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
|
| 139 |
+
function buildHooks({
|
| 140 |
+
api,
|
| 141 |
+
moduleOptions: {
|
| 142 |
+
batch,
|
| 143 |
+
hooks: {
|
| 144 |
+
useDispatch,
|
| 145 |
+
useSelector,
|
| 146 |
+
useStore
|
| 147 |
+
},
|
| 148 |
+
unstable__sideEffectsInRender,
|
| 149 |
+
createSelector
|
| 150 |
+
},
|
| 151 |
+
serializeQueryArgs,
|
| 152 |
+
context
|
| 153 |
+
}) {
|
| 154 |
+
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : useEffect3;
|
| 155 |
+
return {
|
| 156 |
+
buildQueryHooks,
|
| 157 |
+
buildInfiniteQueryHooks,
|
| 158 |
+
buildMutationHook,
|
| 159 |
+
usePrefetch
|
| 160 |
+
};
|
| 161 |
+
function queryStatePreSelector(currentState, lastResult, queryArgs) {
|
| 162 |
+
if ((lastResult == null ? void 0 : lastResult.endpointName) && currentState.isUninitialized) {
|
| 163 |
+
const {
|
| 164 |
+
endpointName
|
| 165 |
+
} = lastResult;
|
| 166 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 167 |
+
if (queryArgs !== skipToken && serializeQueryArgs({
|
| 168 |
+
queryArgs: lastResult.originalArgs,
|
| 169 |
+
endpointDefinition,
|
| 170 |
+
endpointName
|
| 171 |
+
}) === serializeQueryArgs({
|
| 172 |
+
queryArgs,
|
| 173 |
+
endpointDefinition,
|
| 174 |
+
endpointName
|
| 175 |
+
})) lastResult = void 0;
|
| 176 |
+
}
|
| 177 |
+
let data = currentState.isSuccess ? currentState.data : lastResult == null ? void 0 : lastResult.data;
|
| 178 |
+
if (data === void 0) data = currentState.data;
|
| 179 |
+
const hasData = data !== void 0;
|
| 180 |
+
const isFetching = currentState.isLoading;
|
| 181 |
+
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
| 182 |
+
const isSuccess = currentState.isSuccess || hasData && (isFetching && !(lastResult == null ? void 0 : lastResult.isError) || currentState.isUninitialized);
|
| 183 |
+
return __spreadProps(__spreadValues({}, currentState), {
|
| 184 |
+
data,
|
| 185 |
+
currentData: currentState.data,
|
| 186 |
+
isFetching,
|
| 187 |
+
isLoading,
|
| 188 |
+
isSuccess
|
| 189 |
+
});
|
| 190 |
+
}
|
| 191 |
+
function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
|
| 192 |
+
if ((lastResult == null ? void 0 : lastResult.endpointName) && currentState.isUninitialized) {
|
| 193 |
+
const {
|
| 194 |
+
endpointName
|
| 195 |
+
} = lastResult;
|
| 196 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 197 |
+
if (queryArgs !== skipToken && serializeQueryArgs({
|
| 198 |
+
queryArgs: lastResult.originalArgs,
|
| 199 |
+
endpointDefinition,
|
| 200 |
+
endpointName
|
| 201 |
+
}) === serializeQueryArgs({
|
| 202 |
+
queryArgs,
|
| 203 |
+
endpointDefinition,
|
| 204 |
+
endpointName
|
| 205 |
+
})) lastResult = void 0;
|
| 206 |
+
}
|
| 207 |
+
let data = currentState.isSuccess ? currentState.data : lastResult == null ? void 0 : lastResult.data;
|
| 208 |
+
if (data === void 0) data = currentState.data;
|
| 209 |
+
const hasData = data !== void 0;
|
| 210 |
+
const isFetching = currentState.isLoading;
|
| 211 |
+
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
| 212 |
+
const isSuccess = currentState.isSuccess || isFetching && hasData;
|
| 213 |
+
return __spreadProps(__spreadValues({}, currentState), {
|
| 214 |
+
data,
|
| 215 |
+
currentData: currentState.data,
|
| 216 |
+
isFetching,
|
| 217 |
+
isLoading,
|
| 218 |
+
isSuccess
|
| 219 |
+
});
|
| 220 |
+
}
|
| 221 |
+
function usePrefetch(endpointName, defaultOptions) {
|
| 222 |
+
const dispatch = useDispatch();
|
| 223 |
+
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
| 224 |
+
return useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, __spreadValues(__spreadValues({}, stableDefaultOptions), options))), [endpointName, dispatch, stableDefaultOptions]);
|
| 225 |
+
}
|
| 226 |
+
function useQuerySubscriptionCommonImpl(endpointName, arg, _a = {}) {
|
| 227 |
+
var _b = _a, {
|
| 228 |
+
refetchOnReconnect,
|
| 229 |
+
refetchOnFocus,
|
| 230 |
+
refetchOnMountOrArgChange,
|
| 231 |
+
skip = false,
|
| 232 |
+
pollingInterval = 0,
|
| 233 |
+
skipPollingIfUnfocused = false
|
| 234 |
+
} = _b, rest = __objRest(_b, [
|
| 235 |
+
"refetchOnReconnect",
|
| 236 |
+
"refetchOnFocus",
|
| 237 |
+
"refetchOnMountOrArgChange",
|
| 238 |
+
"skip",
|
| 239 |
+
"pollingInterval",
|
| 240 |
+
"skipPollingIfUnfocused"
|
| 241 |
+
]);
|
| 242 |
+
const {
|
| 243 |
+
initiate
|
| 244 |
+
} = api.endpoints[endpointName];
|
| 245 |
+
const dispatch = useDispatch();
|
| 246 |
+
const subscriptionSelectorsRef = useRef3(void 0);
|
| 247 |
+
if (!subscriptionSelectorsRef.current) {
|
| 248 |
+
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
| 249 |
+
if (process.env.NODE_ENV !== "production") {
|
| 250 |
+
if (typeof returnedValue !== "object" || typeof (returnedValue == null ? void 0 : returnedValue.type) === "string") {
|
| 251 |
+
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.
|
| 252 |
+
You must add the middleware for RTK-Query to function correctly!`);
|
| 253 |
+
}
|
| 254 |
+
}
|
| 255 |
+
subscriptionSelectorsRef.current = returnedValue;
|
| 256 |
+
}
|
| 257 |
+
const stableArg = useStableQueryArgs(
|
| 258 |
+
skip ? skipToken : arg,
|
| 259 |
+
// Even if the user provided a per-endpoint `serializeQueryArgs` with
|
| 260 |
+
// a consistent return value, _here_ we want to use the default behavior
|
| 261 |
+
// so we can tell if _anything_ actually changed. Otherwise, we can end up
|
| 262 |
+
// with a case where the query args did change but the serialization doesn't,
|
| 263 |
+
// and then we never try to initiate a refetch.
|
| 264 |
+
defaultSerializeQueryArgs,
|
| 265 |
+
context.endpointDefinitions[endpointName],
|
| 266 |
+
endpointName
|
| 267 |
+
);
|
| 268 |
+
const stableSubscriptionOptions = useShallowStableValue({
|
| 269 |
+
refetchOnReconnect,
|
| 270 |
+
refetchOnFocus,
|
| 271 |
+
pollingInterval,
|
| 272 |
+
skipPollingIfUnfocused
|
| 273 |
+
});
|
| 274 |
+
const initialPageParam = rest.initialPageParam;
|
| 275 |
+
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
| 276 |
+
const promiseRef = useRef3(void 0);
|
| 277 |
+
let {
|
| 278 |
+
queryCacheKey,
|
| 279 |
+
requestId
|
| 280 |
+
} = promiseRef.current || {};
|
| 281 |
+
let currentRenderHasSubscription = false;
|
| 282 |
+
if (queryCacheKey && requestId) {
|
| 283 |
+
currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
|
| 284 |
+
}
|
| 285 |
+
const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
|
| 286 |
+
usePossiblyImmediateEffect(() => {
|
| 287 |
+
if (subscriptionRemoved) {
|
| 288 |
+
promiseRef.current = void 0;
|
| 289 |
+
}
|
| 290 |
+
}, [subscriptionRemoved]);
|
| 291 |
+
usePossiblyImmediateEffect(() => {
|
| 292 |
+
var _a2;
|
| 293 |
+
const lastPromise = promiseRef.current;
|
| 294 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "removeMeOnCompilation") {
|
| 295 |
+
console.log(subscriptionRemoved);
|
| 296 |
+
}
|
| 297 |
+
if (stableArg === skipToken) {
|
| 298 |
+
lastPromise == null ? void 0 : lastPromise.unsubscribe();
|
| 299 |
+
promiseRef.current = void 0;
|
| 300 |
+
return;
|
| 301 |
+
}
|
| 302 |
+
const lastSubscriptionOptions = (_a2 = promiseRef.current) == null ? void 0 : _a2.subscriptionOptions;
|
| 303 |
+
if (!lastPromise || lastPromise.arg !== stableArg) {
|
| 304 |
+
lastPromise == null ? void 0 : lastPromise.unsubscribe();
|
| 305 |
+
const promise = dispatch(initiate(stableArg, __spreadValues({
|
| 306 |
+
subscriptionOptions: stableSubscriptionOptions,
|
| 307 |
+
forceRefetch: refetchOnMountOrArgChange
|
| 308 |
+
}, isInfiniteQueryDefinition(context.endpointDefinitions[endpointName]) ? {
|
| 309 |
+
initialPageParam: stableInitialPageParam
|
| 310 |
+
} : {})));
|
| 311 |
+
promiseRef.current = promise;
|
| 312 |
+
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
| 313 |
+
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
|
| 314 |
+
}
|
| 315 |
+
}, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, endpointName]);
|
| 316 |
+
return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
|
| 317 |
+
}
|
| 318 |
+
function buildUseQueryState(endpointName, preSelector) {
|
| 319 |
+
const useQueryState = (arg, {
|
| 320 |
+
skip = false,
|
| 321 |
+
selectFromResult
|
| 322 |
+
} = {}) => {
|
| 323 |
+
const {
|
| 324 |
+
select
|
| 325 |
+
} = api.endpoints[endpointName];
|
| 326 |
+
const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
|
| 327 |
+
const lastValue = useRef3(void 0);
|
| 328 |
+
const selectDefaultResult = useMemo2(() => (
|
| 329 |
+
// Normally ts-ignores are bad and should be avoided, but we're
|
| 330 |
+
// already casting this selector to be `Selector<any>` anyway,
|
| 331 |
+
// so the inconsistencies don't matter here
|
| 332 |
+
// @ts-ignore
|
| 333 |
+
createSelector([
|
| 334 |
+
// @ts-ignore
|
| 335 |
+
select(stableArg),
|
| 336 |
+
(_, lastResult) => lastResult,
|
| 337 |
+
(_) => stableArg
|
| 338 |
+
], preSelector, {
|
| 339 |
+
memoizeOptions: {
|
| 340 |
+
resultEqualityCheck: shallowEqual2
|
| 341 |
+
}
|
| 342 |
+
})
|
| 343 |
+
), [select, stableArg]);
|
| 344 |
+
const querySelector = useMemo2(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
| 345 |
+
devModeChecks: {
|
| 346 |
+
identityFunctionCheck: "never"
|
| 347 |
+
}
|
| 348 |
+
}) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
|
| 349 |
+
const currentState = useSelector((state) => querySelector(state, lastValue.current), shallowEqual2);
|
| 350 |
+
const store = useStore();
|
| 351 |
+
const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
|
| 352 |
+
useIsomorphicLayoutEffect(() => {
|
| 353 |
+
lastValue.current = newLastValue;
|
| 354 |
+
}, [newLastValue]);
|
| 355 |
+
return currentState;
|
| 356 |
+
};
|
| 357 |
+
return useQueryState;
|
| 358 |
+
}
|
| 359 |
+
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
| 360 |
+
useEffect3(() => {
|
| 361 |
+
return () => {
|
| 362 |
+
var _a, _b;
|
| 363 |
+
(_b = (_a = promiseRef.current) == null ? void 0 : _a.unsubscribe) == null ? void 0 : _b.call(_a);
|
| 364 |
+
promiseRef.current = void 0;
|
| 365 |
+
};
|
| 366 |
+
}, [promiseRef]);
|
| 367 |
+
}
|
| 368 |
+
function refetchOrErrorIfUnmounted(promiseRef) {
|
| 369 |
+
if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
|
| 370 |
+
return promiseRef.current.refetch();
|
| 371 |
+
}
|
| 372 |
+
function buildQueryHooks(endpointName) {
|
| 373 |
+
const useQuerySubscription = (arg, options = {}) => {
|
| 374 |
+
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
| 375 |
+
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
| 376 |
+
return useMemo2(() => ({
|
| 377 |
+
/**
|
| 378 |
+
* A method to manually refetch data for the query
|
| 379 |
+
*/
|
| 380 |
+
refetch: () => refetchOrErrorIfUnmounted(promiseRef)
|
| 381 |
+
}), [promiseRef]);
|
| 382 |
+
};
|
| 383 |
+
const useLazyQuerySubscription = ({
|
| 384 |
+
refetchOnReconnect,
|
| 385 |
+
refetchOnFocus,
|
| 386 |
+
pollingInterval = 0,
|
| 387 |
+
skipPollingIfUnfocused = false
|
| 388 |
+
} = {}) => {
|
| 389 |
+
const {
|
| 390 |
+
initiate
|
| 391 |
+
} = api.endpoints[endpointName];
|
| 392 |
+
const dispatch = useDispatch();
|
| 393 |
+
const [arg, setArg] = useState(UNINITIALIZED_VALUE);
|
| 394 |
+
const promiseRef = useRef3(void 0);
|
| 395 |
+
const stableSubscriptionOptions = useShallowStableValue({
|
| 396 |
+
refetchOnReconnect,
|
| 397 |
+
refetchOnFocus,
|
| 398 |
+
pollingInterval,
|
| 399 |
+
skipPollingIfUnfocused
|
| 400 |
+
});
|
| 401 |
+
usePossiblyImmediateEffect(() => {
|
| 402 |
+
var _a, _b;
|
| 403 |
+
const lastSubscriptionOptions = (_a = promiseRef.current) == null ? void 0 : _a.subscriptionOptions;
|
| 404 |
+
if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
| 405 |
+
(_b = promiseRef.current) == null ? void 0 : _b.updateSubscriptionOptions(stableSubscriptionOptions);
|
| 406 |
+
}
|
| 407 |
+
}, [stableSubscriptionOptions]);
|
| 408 |
+
const subscriptionOptionsRef = useRef3(stableSubscriptionOptions);
|
| 409 |
+
usePossiblyImmediateEffect(() => {
|
| 410 |
+
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
| 411 |
+
}, [stableSubscriptionOptions]);
|
| 412 |
+
const trigger = useCallback(function(arg2, preferCacheValue = false) {
|
| 413 |
+
let promise;
|
| 414 |
+
batch(() => {
|
| 415 |
+
var _a;
|
| 416 |
+
(_a = promiseRef.current) == null ? void 0 : _a.unsubscribe();
|
| 417 |
+
promiseRef.current = promise = dispatch(initiate(arg2, {
|
| 418 |
+
subscriptionOptions: subscriptionOptionsRef.current,
|
| 419 |
+
forceRefetch: !preferCacheValue
|
| 420 |
+
}));
|
| 421 |
+
setArg(arg2);
|
| 422 |
+
});
|
| 423 |
+
return promise;
|
| 424 |
+
}, [dispatch, initiate]);
|
| 425 |
+
const reset = useCallback(() => {
|
| 426 |
+
var _a, _b;
|
| 427 |
+
if ((_a = promiseRef.current) == null ? void 0 : _a.queryCacheKey) {
|
| 428 |
+
dispatch(api.internalActions.removeQueryResult({
|
| 429 |
+
queryCacheKey: (_b = promiseRef.current) == null ? void 0 : _b.queryCacheKey
|
| 430 |
+
}));
|
| 431 |
+
}
|
| 432 |
+
}, [dispatch]);
|
| 433 |
+
useEffect3(() => {
|
| 434 |
+
return () => {
|
| 435 |
+
var _a;
|
| 436 |
+
(_a = promiseRef == null ? void 0 : promiseRef.current) == null ? void 0 : _a.unsubscribe();
|
| 437 |
+
};
|
| 438 |
+
}, []);
|
| 439 |
+
useEffect3(() => {
|
| 440 |
+
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
| 441 |
+
trigger(arg, true);
|
| 442 |
+
}
|
| 443 |
+
}, [arg, trigger]);
|
| 444 |
+
return useMemo2(() => [trigger, arg, {
|
| 445 |
+
reset
|
| 446 |
+
}], [trigger, arg, reset]);
|
| 447 |
+
};
|
| 448 |
+
const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
|
| 449 |
+
return {
|
| 450 |
+
useQueryState,
|
| 451 |
+
useQuerySubscription,
|
| 452 |
+
useLazyQuerySubscription,
|
| 453 |
+
useLazyQuery(options) {
|
| 454 |
+
const [trigger, arg, {
|
| 455 |
+
reset
|
| 456 |
+
}] = useLazyQuerySubscription(options);
|
| 457 |
+
const queryStateResults = useQueryState(arg, __spreadProps(__spreadValues({}, options), {
|
| 458 |
+
skip: arg === UNINITIALIZED_VALUE
|
| 459 |
+
}));
|
| 460 |
+
const info = useMemo2(() => ({
|
| 461 |
+
lastArg: arg
|
| 462 |
+
}), [arg]);
|
| 463 |
+
return useMemo2(() => [trigger, __spreadProps(__spreadValues({}, queryStateResults), {
|
| 464 |
+
reset
|
| 465 |
+
}), info], [trigger, queryStateResults, reset, info]);
|
| 466 |
+
},
|
| 467 |
+
useQuery(arg, options) {
|
| 468 |
+
const querySubscriptionResults = useQuerySubscription(arg, options);
|
| 469 |
+
const queryStateResults = useQueryState(arg, __spreadValues({
|
| 470 |
+
selectFromResult: arg === skipToken || (options == null ? void 0 : options.skip) ? void 0 : noPendingQueryStateSelector
|
| 471 |
+
}, options));
|
| 472 |
+
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
| 473 |
+
useDebugValue(debugValue);
|
| 474 |
+
return useMemo2(() => __spreadValues(__spreadValues({}, queryStateResults), querySubscriptionResults), [queryStateResults, querySubscriptionResults]);
|
| 475 |
+
}
|
| 476 |
+
};
|
| 477 |
+
}
|
| 478 |
+
function buildInfiniteQueryHooks(endpointName) {
|
| 479 |
+
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
| 480 |
+
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
| 481 |
+
const subscriptionOptionsRef = useRef3(stableSubscriptionOptions);
|
| 482 |
+
usePossiblyImmediateEffect(() => {
|
| 483 |
+
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
| 484 |
+
}, [stableSubscriptionOptions]);
|
| 485 |
+
const trigger = useCallback(function(arg2, direction) {
|
| 486 |
+
let promise;
|
| 487 |
+
batch(() => {
|
| 488 |
+
var _a;
|
| 489 |
+
(_a = promiseRef.current) == null ? void 0 : _a.unsubscribe();
|
| 490 |
+
promiseRef.current = promise = dispatch(initiate(arg2, {
|
| 491 |
+
subscriptionOptions: subscriptionOptionsRef.current,
|
| 492 |
+
direction
|
| 493 |
+
}));
|
| 494 |
+
});
|
| 495 |
+
return promise;
|
| 496 |
+
}, [promiseRef, dispatch, initiate]);
|
| 497 |
+
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
| 498 |
+
const stableArg = useStableQueryArgs(
|
| 499 |
+
options.skip ? skipToken : arg,
|
| 500 |
+
// Even if the user provided a per-endpoint `serializeQueryArgs` with
|
| 501 |
+
// a consistent return value, _here_ we want to use the default behavior
|
| 502 |
+
// so we can tell if _anything_ actually changed. Otherwise, we can end up
|
| 503 |
+
// with a case where the query args did change but the serialization doesn't,
|
| 504 |
+
// and then we never try to initiate a refetch.
|
| 505 |
+
defaultSerializeQueryArgs,
|
| 506 |
+
context.endpointDefinitions[endpointName],
|
| 507 |
+
endpointName
|
| 508 |
+
);
|
| 509 |
+
const refetch = useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
|
| 510 |
+
return useMemo2(() => {
|
| 511 |
+
const fetchNextPage = () => {
|
| 512 |
+
return trigger(stableArg, "forward");
|
| 513 |
+
};
|
| 514 |
+
const fetchPreviousPage = () => {
|
| 515 |
+
return trigger(stableArg, "backward");
|
| 516 |
+
};
|
| 517 |
+
return {
|
| 518 |
+
trigger,
|
| 519 |
+
/**
|
| 520 |
+
* A method to manually refetch data for the query
|
| 521 |
+
*/
|
| 522 |
+
refetch,
|
| 523 |
+
fetchNextPage,
|
| 524 |
+
fetchPreviousPage
|
| 525 |
+
};
|
| 526 |
+
}, [refetch, trigger, stableArg]);
|
| 527 |
+
};
|
| 528 |
+
const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
|
| 529 |
+
return {
|
| 530 |
+
useInfiniteQueryState,
|
| 531 |
+
useInfiniteQuerySubscription,
|
| 532 |
+
useInfiniteQuery(arg, options) {
|
| 533 |
+
const {
|
| 534 |
+
refetch,
|
| 535 |
+
fetchNextPage,
|
| 536 |
+
fetchPreviousPage
|
| 537 |
+
} = useInfiniteQuerySubscription(arg, options);
|
| 538 |
+
const queryStateResults = useInfiniteQueryState(arg, __spreadValues({
|
| 539 |
+
selectFromResult: arg === skipToken || (options == null ? void 0 : options.skip) ? void 0 : noPendingQueryStateSelector
|
| 540 |
+
}, options));
|
| 541 |
+
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
| 542 |
+
useDebugValue(debugValue);
|
| 543 |
+
return useMemo2(() => __spreadProps(__spreadValues({}, queryStateResults), {
|
| 544 |
+
fetchNextPage,
|
| 545 |
+
fetchPreviousPage,
|
| 546 |
+
refetch
|
| 547 |
+
}), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
|
| 548 |
+
}
|
| 549 |
+
};
|
| 550 |
+
}
|
| 551 |
+
function buildMutationHook(name) {
|
| 552 |
+
return ({
|
| 553 |
+
selectFromResult,
|
| 554 |
+
fixedCacheKey
|
| 555 |
+
} = {}) => {
|
| 556 |
+
const {
|
| 557 |
+
select,
|
| 558 |
+
initiate
|
| 559 |
+
} = api.endpoints[name];
|
| 560 |
+
const dispatch = useDispatch();
|
| 561 |
+
const [promise, setPromise] = useState();
|
| 562 |
+
useEffect3(() => () => {
|
| 563 |
+
if (!(promise == null ? void 0 : promise.arg.fixedCacheKey)) {
|
| 564 |
+
promise == null ? void 0 : promise.reset();
|
| 565 |
+
}
|
| 566 |
+
}, [promise]);
|
| 567 |
+
const triggerMutation = useCallback(function(arg) {
|
| 568 |
+
const promise2 = dispatch(initiate(arg, {
|
| 569 |
+
fixedCacheKey
|
| 570 |
+
}));
|
| 571 |
+
setPromise(promise2);
|
| 572 |
+
return promise2;
|
| 573 |
+
}, [dispatch, initiate, fixedCacheKey]);
|
| 574 |
+
const {
|
| 575 |
+
requestId
|
| 576 |
+
} = promise || {};
|
| 577 |
+
const selectDefaultResult = useMemo2(() => select({
|
| 578 |
+
fixedCacheKey,
|
| 579 |
+
requestId: promise == null ? void 0 : promise.requestId
|
| 580 |
+
}), [fixedCacheKey, promise, select]);
|
| 581 |
+
const mutationSelector = useMemo2(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
| 582 |
+
const currentState = useSelector(mutationSelector, shallowEqual2);
|
| 583 |
+
const originalArgs = fixedCacheKey == null ? promise == null ? void 0 : promise.arg.originalArgs : void 0;
|
| 584 |
+
const reset = useCallback(() => {
|
| 585 |
+
batch(() => {
|
| 586 |
+
if (promise) {
|
| 587 |
+
setPromise(void 0);
|
| 588 |
+
}
|
| 589 |
+
if (fixedCacheKey) {
|
| 590 |
+
dispatch(api.internalActions.removeMutationResult({
|
| 591 |
+
requestId,
|
| 592 |
+
fixedCacheKey
|
| 593 |
+
}));
|
| 594 |
+
}
|
| 595 |
+
});
|
| 596 |
+
}, [dispatch, fixedCacheKey, promise, requestId]);
|
| 597 |
+
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
| 598 |
+
useDebugValue(debugValue);
|
| 599 |
+
const finalState = useMemo2(() => __spreadProps(__spreadValues({}, currentState), {
|
| 600 |
+
originalArgs,
|
| 601 |
+
reset
|
| 602 |
+
}), [currentState, originalArgs, reset]);
|
| 603 |
+
return useMemo2(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
| 604 |
+
};
|
| 605 |
+
}
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
// src/query/react/module.ts
|
| 609 |
+
var reactHooksModuleName = /* @__PURE__ */ Symbol();
|
| 610 |
+
var reactHooksModule = (_a = {}) => {
|
| 611 |
+
var _b = _a, {
|
| 612 |
+
batch = rrBatch,
|
| 613 |
+
hooks = {
|
| 614 |
+
useDispatch: rrUseDispatch,
|
| 615 |
+
useSelector: rrUseSelector,
|
| 616 |
+
useStore: rrUseStore
|
| 617 |
+
},
|
| 618 |
+
createSelector = _createSelector,
|
| 619 |
+
unstable__sideEffectsInRender = false
|
| 620 |
+
} = _b, rest = __objRest(_b, [
|
| 621 |
+
"batch",
|
| 622 |
+
"hooks",
|
| 623 |
+
"createSelector",
|
| 624 |
+
"unstable__sideEffectsInRender"
|
| 625 |
+
]);
|
| 626 |
+
if (process.env.NODE_ENV !== "production") {
|
| 627 |
+
const hookNames = ["useDispatch", "useSelector", "useStore"];
|
| 628 |
+
let warned = false;
|
| 629 |
+
for (const hookName of hookNames) {
|
| 630 |
+
if (countObjectKeys(rest) > 0) {
|
| 631 |
+
if (rest[hookName]) {
|
| 632 |
+
if (!warned) {
|
| 633 |
+
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 } })`");
|
| 634 |
+
warned = true;
|
| 635 |
+
}
|
| 636 |
+
}
|
| 637 |
+
hooks[hookName] = rest[hookName];
|
| 638 |
+
}
|
| 639 |
+
if (typeof hooks[hookName] !== "function") {
|
| 640 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage3(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(", ")}.
|
| 641 |
+
Hook ${hookName} was either not provided or not a function.`);
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
return {
|
| 646 |
+
name: reactHooksModuleName,
|
| 647 |
+
init(api, {
|
| 648 |
+
serializeQueryArgs
|
| 649 |
+
}, context) {
|
| 650 |
+
const anyApi = api;
|
| 651 |
+
const {
|
| 652 |
+
buildQueryHooks,
|
| 653 |
+
buildInfiniteQueryHooks,
|
| 654 |
+
buildMutationHook,
|
| 655 |
+
usePrefetch
|
| 656 |
+
} = buildHooks({
|
| 657 |
+
api,
|
| 658 |
+
moduleOptions: {
|
| 659 |
+
batch,
|
| 660 |
+
hooks,
|
| 661 |
+
unstable__sideEffectsInRender,
|
| 662 |
+
createSelector
|
| 663 |
+
},
|
| 664 |
+
serializeQueryArgs,
|
| 665 |
+
context
|
| 666 |
+
});
|
| 667 |
+
safeAssign(anyApi, {
|
| 668 |
+
usePrefetch
|
| 669 |
+
});
|
| 670 |
+
safeAssign(context, {
|
| 671 |
+
batch
|
| 672 |
+
});
|
| 673 |
+
return {
|
| 674 |
+
injectEndpoint(endpointName, definition) {
|
| 675 |
+
if (isQueryDefinition(definition)) {
|
| 676 |
+
const {
|
| 677 |
+
useQuery,
|
| 678 |
+
useLazyQuery,
|
| 679 |
+
useLazyQuerySubscription,
|
| 680 |
+
useQueryState,
|
| 681 |
+
useQuerySubscription
|
| 682 |
+
} = buildQueryHooks(endpointName);
|
| 683 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 684 |
+
useQuery,
|
| 685 |
+
useLazyQuery,
|
| 686 |
+
useLazyQuerySubscription,
|
| 687 |
+
useQueryState,
|
| 688 |
+
useQuerySubscription
|
| 689 |
+
});
|
| 690 |
+
api[`use${capitalize(endpointName)}Query`] = useQuery;
|
| 691 |
+
api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
|
| 692 |
+
}
|
| 693 |
+
if (isMutationDefinition(definition)) {
|
| 694 |
+
const useMutation = buildMutationHook(endpointName);
|
| 695 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 696 |
+
useMutation
|
| 697 |
+
});
|
| 698 |
+
api[`use${capitalize(endpointName)}Mutation`] = useMutation;
|
| 699 |
+
} else if (isInfiniteQueryDefinition(definition)) {
|
| 700 |
+
const {
|
| 701 |
+
useInfiniteQuery,
|
| 702 |
+
useInfiniteQuerySubscription,
|
| 703 |
+
useInfiniteQueryState
|
| 704 |
+
} = buildInfiniteQueryHooks(endpointName);
|
| 705 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 706 |
+
useInfiniteQuery,
|
| 707 |
+
useInfiniteQuerySubscription,
|
| 708 |
+
useInfiniteQueryState
|
| 709 |
+
});
|
| 710 |
+
api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
|
| 711 |
+
}
|
| 712 |
+
}
|
| 713 |
+
};
|
| 714 |
+
}
|
| 715 |
+
};
|
| 716 |
+
};
|
| 717 |
+
|
| 718 |
+
// src/query/react/index.ts
|
| 719 |
+
export * from "@reduxjs/toolkit/query";
|
| 720 |
+
|
| 721 |
+
// src/query/react/ApiProvider.tsx
|
| 722 |
+
import { configureStore, formatProdErrorMessage as _formatProdErrorMessage4 } from "@reduxjs/toolkit";
|
| 723 |
+
import { useContext } from "react";
|
| 724 |
+
import { useEffect as useEffect4 } from "react";
|
| 725 |
+
import * as React from "react";
|
| 726 |
+
import { Provider, ReactReduxContext } from "react-redux";
|
| 727 |
+
import { setupListeners } from "@reduxjs/toolkit/query";
|
| 728 |
+
function ApiProvider(props) {
|
| 729 |
+
const context = props.context || ReactReduxContext;
|
| 730 |
+
const existingContext = useContext(context);
|
| 731 |
+
if (existingContext) {
|
| 732 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage4(35) : "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.");
|
| 733 |
+
}
|
| 734 |
+
const [store] = React.useState(() => configureStore({
|
| 735 |
+
reducer: {
|
| 736 |
+
[props.api.reducerPath]: props.api.reducer
|
| 737 |
+
},
|
| 738 |
+
middleware: (gDM) => gDM().concat(props.api.middleware)
|
| 739 |
+
}));
|
| 740 |
+
useEffect4(() => props.setupListeners === false ? void 0 : setupListeners(store.dispatch, props.setupListeners), [props.setupListeners, store.dispatch]);
|
| 741 |
+
return /* @__PURE__ */ React.createElement(Provider, { store, context }, props.children);
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
// src/query/react/index.ts
|
| 745 |
+
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
| 746 |
+
export {
|
| 747 |
+
ApiProvider,
|
| 748 |
+
UNINITIALIZED_VALUE,
|
| 749 |
+
createApi,
|
| 750 |
+
reactHooksModule,
|
| 751 |
+
reactHooksModuleName
|
| 752 |
+
};
|
| 753 |
+
//# sourceMappingURL=rtk-query-react.legacy-esm.js.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.legacy-esm.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs
ADDED
|
@@ -0,0 +1,718 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/query/react/index.ts
|
| 2 |
+
import { buildCreateApi, coreModule } from "@reduxjs/toolkit/query";
|
| 3 |
+
|
| 4 |
+
// src/query/react/module.ts
|
| 5 |
+
import { formatProdErrorMessage as _formatProdErrorMessage3 } from "@reduxjs/toolkit";
|
| 6 |
+
import { batch as rrBatch, useDispatch as rrUseDispatch, useSelector as rrUseSelector, useStore as rrUseStore } from "react-redux";
|
| 7 |
+
import { createSelector as _createSelector } from "reselect";
|
| 8 |
+
|
| 9 |
+
// src/query/utils/capitalize.ts
|
| 10 |
+
function capitalize(str) {
|
| 11 |
+
return str.replace(str[0], str[0].toUpperCase());
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
// src/query/utils/countObjectKeys.ts
|
| 15 |
+
function countObjectKeys(obj) {
|
| 16 |
+
let count = 0;
|
| 17 |
+
for (const _key in obj) {
|
| 18 |
+
count++;
|
| 19 |
+
}
|
| 20 |
+
return count;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
// src/query/endpointDefinitions.ts
|
| 24 |
+
function isQueryDefinition(e) {
|
| 25 |
+
return e.type === "query" /* query */;
|
| 26 |
+
}
|
| 27 |
+
function isMutationDefinition(e) {
|
| 28 |
+
return e.type === "mutation" /* mutation */;
|
| 29 |
+
}
|
| 30 |
+
function isInfiniteQueryDefinition(e) {
|
| 31 |
+
return e.type === "infinitequery" /* infinitequery */;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
// src/query/tsHelpers.ts
|
| 35 |
+
function safeAssign(target, ...args) {
|
| 36 |
+
return Object.assign(target, ...args);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// src/query/react/buildHooks.ts
|
| 40 |
+
import { formatProdErrorMessage as _formatProdErrorMessage, formatProdErrorMessage as _formatProdErrorMessage2 } from "@reduxjs/toolkit";
|
| 41 |
+
import { defaultSerializeQueryArgs, QueryStatus, skipToken } from "@reduxjs/toolkit/query";
|
| 42 |
+
import { useCallback, useDebugValue, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo2, useRef as useRef3, useState } from "react";
|
| 43 |
+
import { shallowEqual as shallowEqual2 } from "react-redux";
|
| 44 |
+
|
| 45 |
+
// src/query/react/constants.ts
|
| 46 |
+
var UNINITIALIZED_VALUE = Symbol();
|
| 47 |
+
|
| 48 |
+
// src/query/react/useSerializedStableValue.ts
|
| 49 |
+
import { useEffect, useRef, useMemo } from "react";
|
| 50 |
+
function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
|
| 51 |
+
const incoming = useMemo(() => ({
|
| 52 |
+
queryArgs,
|
| 53 |
+
serialized: typeof queryArgs == "object" ? serialize({
|
| 54 |
+
queryArgs,
|
| 55 |
+
endpointDefinition,
|
| 56 |
+
endpointName
|
| 57 |
+
}) : queryArgs
|
| 58 |
+
}), [queryArgs, serialize, endpointDefinition, endpointName]);
|
| 59 |
+
const cache = useRef(incoming);
|
| 60 |
+
useEffect(() => {
|
| 61 |
+
if (cache.current.serialized !== incoming.serialized) {
|
| 62 |
+
cache.current = incoming;
|
| 63 |
+
}
|
| 64 |
+
}, [incoming]);
|
| 65 |
+
return cache.current.serialized === incoming.serialized ? cache.current.queryArgs : queryArgs;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
// src/query/react/useShallowStableValue.ts
|
| 69 |
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
| 70 |
+
import { shallowEqual } from "react-redux";
|
| 71 |
+
function useShallowStableValue(value) {
|
| 72 |
+
const cache = useRef2(value);
|
| 73 |
+
useEffect2(() => {
|
| 74 |
+
if (!shallowEqual(cache.current, value)) {
|
| 75 |
+
cache.current = value;
|
| 76 |
+
}
|
| 77 |
+
}, [value]);
|
| 78 |
+
return shallowEqual(cache.current, value) ? cache.current : value;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// src/query/react/buildHooks.ts
|
| 82 |
+
var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
| 83 |
+
var isDOM = /* @__PURE__ */ canUseDOM();
|
| 84 |
+
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
| 85 |
+
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
| 86 |
+
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? useLayoutEffect : useEffect3;
|
| 87 |
+
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
| 88 |
+
var noPendingQueryStateSelector = (selected) => {
|
| 89 |
+
if (selected.isUninitialized) {
|
| 90 |
+
return {
|
| 91 |
+
...selected,
|
| 92 |
+
isUninitialized: false,
|
| 93 |
+
isFetching: true,
|
| 94 |
+
isLoading: selected.data !== void 0 ? false : true,
|
| 95 |
+
status: QueryStatus.pending
|
| 96 |
+
};
|
| 97 |
+
}
|
| 98 |
+
return selected;
|
| 99 |
+
};
|
| 100 |
+
function pick(obj, ...keys) {
|
| 101 |
+
const ret = {};
|
| 102 |
+
keys.forEach((key) => {
|
| 103 |
+
ret[key] = obj[key];
|
| 104 |
+
});
|
| 105 |
+
return ret;
|
| 106 |
+
}
|
| 107 |
+
var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
|
| 108 |
+
function buildHooks({
|
| 109 |
+
api,
|
| 110 |
+
moduleOptions: {
|
| 111 |
+
batch,
|
| 112 |
+
hooks: {
|
| 113 |
+
useDispatch,
|
| 114 |
+
useSelector,
|
| 115 |
+
useStore
|
| 116 |
+
},
|
| 117 |
+
unstable__sideEffectsInRender,
|
| 118 |
+
createSelector
|
| 119 |
+
},
|
| 120 |
+
serializeQueryArgs,
|
| 121 |
+
context
|
| 122 |
+
}) {
|
| 123 |
+
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : useEffect3;
|
| 124 |
+
return {
|
| 125 |
+
buildQueryHooks,
|
| 126 |
+
buildInfiniteQueryHooks,
|
| 127 |
+
buildMutationHook,
|
| 128 |
+
usePrefetch
|
| 129 |
+
};
|
| 130 |
+
function queryStatePreSelector(currentState, lastResult, queryArgs) {
|
| 131 |
+
if (lastResult?.endpointName && currentState.isUninitialized) {
|
| 132 |
+
const {
|
| 133 |
+
endpointName
|
| 134 |
+
} = lastResult;
|
| 135 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 136 |
+
if (queryArgs !== skipToken && serializeQueryArgs({
|
| 137 |
+
queryArgs: lastResult.originalArgs,
|
| 138 |
+
endpointDefinition,
|
| 139 |
+
endpointName
|
| 140 |
+
}) === serializeQueryArgs({
|
| 141 |
+
queryArgs,
|
| 142 |
+
endpointDefinition,
|
| 143 |
+
endpointName
|
| 144 |
+
})) lastResult = void 0;
|
| 145 |
+
}
|
| 146 |
+
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
| 147 |
+
if (data === void 0) data = currentState.data;
|
| 148 |
+
const hasData = data !== void 0;
|
| 149 |
+
const isFetching = currentState.isLoading;
|
| 150 |
+
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
| 151 |
+
const isSuccess = currentState.isSuccess || hasData && (isFetching && !lastResult?.isError || currentState.isUninitialized);
|
| 152 |
+
return {
|
| 153 |
+
...currentState,
|
| 154 |
+
data,
|
| 155 |
+
currentData: currentState.data,
|
| 156 |
+
isFetching,
|
| 157 |
+
isLoading,
|
| 158 |
+
isSuccess
|
| 159 |
+
};
|
| 160 |
+
}
|
| 161 |
+
function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
|
| 162 |
+
if (lastResult?.endpointName && currentState.isUninitialized) {
|
| 163 |
+
const {
|
| 164 |
+
endpointName
|
| 165 |
+
} = lastResult;
|
| 166 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 167 |
+
if (queryArgs !== skipToken && serializeQueryArgs({
|
| 168 |
+
queryArgs: lastResult.originalArgs,
|
| 169 |
+
endpointDefinition,
|
| 170 |
+
endpointName
|
| 171 |
+
}) === serializeQueryArgs({
|
| 172 |
+
queryArgs,
|
| 173 |
+
endpointDefinition,
|
| 174 |
+
endpointName
|
| 175 |
+
})) lastResult = void 0;
|
| 176 |
+
}
|
| 177 |
+
let data = currentState.isSuccess ? currentState.data : lastResult?.data;
|
| 178 |
+
if (data === void 0) data = currentState.data;
|
| 179 |
+
const hasData = data !== void 0;
|
| 180 |
+
const isFetching = currentState.isLoading;
|
| 181 |
+
const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
|
| 182 |
+
const isSuccess = currentState.isSuccess || isFetching && hasData;
|
| 183 |
+
return {
|
| 184 |
+
...currentState,
|
| 185 |
+
data,
|
| 186 |
+
currentData: currentState.data,
|
| 187 |
+
isFetching,
|
| 188 |
+
isLoading,
|
| 189 |
+
isSuccess
|
| 190 |
+
};
|
| 191 |
+
}
|
| 192 |
+
function usePrefetch(endpointName, defaultOptions) {
|
| 193 |
+
const dispatch = useDispatch();
|
| 194 |
+
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
| 195 |
+
return useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
|
| 196 |
+
...stableDefaultOptions,
|
| 197 |
+
...options
|
| 198 |
+
})), [endpointName, dispatch, stableDefaultOptions]);
|
| 199 |
+
}
|
| 200 |
+
function useQuerySubscriptionCommonImpl(endpointName, arg, {
|
| 201 |
+
refetchOnReconnect,
|
| 202 |
+
refetchOnFocus,
|
| 203 |
+
refetchOnMountOrArgChange,
|
| 204 |
+
skip = false,
|
| 205 |
+
pollingInterval = 0,
|
| 206 |
+
skipPollingIfUnfocused = false,
|
| 207 |
+
...rest
|
| 208 |
+
} = {}) {
|
| 209 |
+
const {
|
| 210 |
+
initiate
|
| 211 |
+
} = api.endpoints[endpointName];
|
| 212 |
+
const dispatch = useDispatch();
|
| 213 |
+
const subscriptionSelectorsRef = useRef3(void 0);
|
| 214 |
+
if (!subscriptionSelectorsRef.current) {
|
| 215 |
+
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
| 216 |
+
if (process.env.NODE_ENV !== "production") {
|
| 217 |
+
if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
|
| 218 |
+
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.
|
| 219 |
+
You must add the middleware for RTK-Query to function correctly!`);
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
subscriptionSelectorsRef.current = returnedValue;
|
| 223 |
+
}
|
| 224 |
+
const stableArg = useStableQueryArgs(
|
| 225 |
+
skip ? skipToken : arg,
|
| 226 |
+
// Even if the user provided a per-endpoint `serializeQueryArgs` with
|
| 227 |
+
// a consistent return value, _here_ we want to use the default behavior
|
| 228 |
+
// so we can tell if _anything_ actually changed. Otherwise, we can end up
|
| 229 |
+
// with a case where the query args did change but the serialization doesn't,
|
| 230 |
+
// and then we never try to initiate a refetch.
|
| 231 |
+
defaultSerializeQueryArgs,
|
| 232 |
+
context.endpointDefinitions[endpointName],
|
| 233 |
+
endpointName
|
| 234 |
+
);
|
| 235 |
+
const stableSubscriptionOptions = useShallowStableValue({
|
| 236 |
+
refetchOnReconnect,
|
| 237 |
+
refetchOnFocus,
|
| 238 |
+
pollingInterval,
|
| 239 |
+
skipPollingIfUnfocused
|
| 240 |
+
});
|
| 241 |
+
const initialPageParam = rest.initialPageParam;
|
| 242 |
+
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
| 243 |
+
const promiseRef = useRef3(void 0);
|
| 244 |
+
let {
|
| 245 |
+
queryCacheKey,
|
| 246 |
+
requestId
|
| 247 |
+
} = promiseRef.current || {};
|
| 248 |
+
let currentRenderHasSubscription = false;
|
| 249 |
+
if (queryCacheKey && requestId) {
|
| 250 |
+
currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
|
| 251 |
+
}
|
| 252 |
+
const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
|
| 253 |
+
usePossiblyImmediateEffect(() => {
|
| 254 |
+
if (subscriptionRemoved) {
|
| 255 |
+
promiseRef.current = void 0;
|
| 256 |
+
}
|
| 257 |
+
}, [subscriptionRemoved]);
|
| 258 |
+
usePossiblyImmediateEffect(() => {
|
| 259 |
+
const lastPromise = promiseRef.current;
|
| 260 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "removeMeOnCompilation") {
|
| 261 |
+
console.log(subscriptionRemoved);
|
| 262 |
+
}
|
| 263 |
+
if (stableArg === skipToken) {
|
| 264 |
+
lastPromise?.unsubscribe();
|
| 265 |
+
promiseRef.current = void 0;
|
| 266 |
+
return;
|
| 267 |
+
}
|
| 268 |
+
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
| 269 |
+
if (!lastPromise || lastPromise.arg !== stableArg) {
|
| 270 |
+
lastPromise?.unsubscribe();
|
| 271 |
+
const promise = dispatch(initiate(stableArg, {
|
| 272 |
+
subscriptionOptions: stableSubscriptionOptions,
|
| 273 |
+
forceRefetch: refetchOnMountOrArgChange,
|
| 274 |
+
...isInfiniteQueryDefinition(context.endpointDefinitions[endpointName]) ? {
|
| 275 |
+
initialPageParam: stableInitialPageParam
|
| 276 |
+
} : {}
|
| 277 |
+
}));
|
| 278 |
+
promiseRef.current = promise;
|
| 279 |
+
} else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
| 280 |
+
lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
|
| 281 |
+
}
|
| 282 |
+
}, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, endpointName]);
|
| 283 |
+
return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
|
| 284 |
+
}
|
| 285 |
+
function buildUseQueryState(endpointName, preSelector) {
|
| 286 |
+
const useQueryState = (arg, {
|
| 287 |
+
skip = false,
|
| 288 |
+
selectFromResult
|
| 289 |
+
} = {}) => {
|
| 290 |
+
const {
|
| 291 |
+
select
|
| 292 |
+
} = api.endpoints[endpointName];
|
| 293 |
+
const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
|
| 294 |
+
const lastValue = useRef3(void 0);
|
| 295 |
+
const selectDefaultResult = useMemo2(() => (
|
| 296 |
+
// Normally ts-ignores are bad and should be avoided, but we're
|
| 297 |
+
// already casting this selector to be `Selector<any>` anyway,
|
| 298 |
+
// so the inconsistencies don't matter here
|
| 299 |
+
// @ts-ignore
|
| 300 |
+
createSelector([
|
| 301 |
+
// @ts-ignore
|
| 302 |
+
select(stableArg),
|
| 303 |
+
(_, lastResult) => lastResult,
|
| 304 |
+
(_) => stableArg
|
| 305 |
+
], preSelector, {
|
| 306 |
+
memoizeOptions: {
|
| 307 |
+
resultEqualityCheck: shallowEqual2
|
| 308 |
+
}
|
| 309 |
+
})
|
| 310 |
+
), [select, stableArg]);
|
| 311 |
+
const querySelector = useMemo2(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
| 312 |
+
devModeChecks: {
|
| 313 |
+
identityFunctionCheck: "never"
|
| 314 |
+
}
|
| 315 |
+
}) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
|
| 316 |
+
const currentState = useSelector((state) => querySelector(state, lastValue.current), shallowEqual2);
|
| 317 |
+
const store = useStore();
|
| 318 |
+
const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
|
| 319 |
+
useIsomorphicLayoutEffect(() => {
|
| 320 |
+
lastValue.current = newLastValue;
|
| 321 |
+
}, [newLastValue]);
|
| 322 |
+
return currentState;
|
| 323 |
+
};
|
| 324 |
+
return useQueryState;
|
| 325 |
+
}
|
| 326 |
+
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
| 327 |
+
useEffect3(() => {
|
| 328 |
+
return () => {
|
| 329 |
+
promiseRef.current?.unsubscribe?.();
|
| 330 |
+
promiseRef.current = void 0;
|
| 331 |
+
};
|
| 332 |
+
}, [promiseRef]);
|
| 333 |
+
}
|
| 334 |
+
function refetchOrErrorIfUnmounted(promiseRef) {
|
| 335 |
+
if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
|
| 336 |
+
return promiseRef.current.refetch();
|
| 337 |
+
}
|
| 338 |
+
function buildQueryHooks(endpointName) {
|
| 339 |
+
const useQuerySubscription = (arg, options = {}) => {
|
| 340 |
+
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
| 341 |
+
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
| 342 |
+
return useMemo2(() => ({
|
| 343 |
+
/**
|
| 344 |
+
* A method to manually refetch data for the query
|
| 345 |
+
*/
|
| 346 |
+
refetch: () => refetchOrErrorIfUnmounted(promiseRef)
|
| 347 |
+
}), [promiseRef]);
|
| 348 |
+
};
|
| 349 |
+
const useLazyQuerySubscription = ({
|
| 350 |
+
refetchOnReconnect,
|
| 351 |
+
refetchOnFocus,
|
| 352 |
+
pollingInterval = 0,
|
| 353 |
+
skipPollingIfUnfocused = false
|
| 354 |
+
} = {}) => {
|
| 355 |
+
const {
|
| 356 |
+
initiate
|
| 357 |
+
} = api.endpoints[endpointName];
|
| 358 |
+
const dispatch = useDispatch();
|
| 359 |
+
const [arg, setArg] = useState(UNINITIALIZED_VALUE);
|
| 360 |
+
const promiseRef = useRef3(void 0);
|
| 361 |
+
const stableSubscriptionOptions = useShallowStableValue({
|
| 362 |
+
refetchOnReconnect,
|
| 363 |
+
refetchOnFocus,
|
| 364 |
+
pollingInterval,
|
| 365 |
+
skipPollingIfUnfocused
|
| 366 |
+
});
|
| 367 |
+
usePossiblyImmediateEffect(() => {
|
| 368 |
+
const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
|
| 369 |
+
if (stableSubscriptionOptions !== lastSubscriptionOptions) {
|
| 370 |
+
promiseRef.current?.updateSubscriptionOptions(stableSubscriptionOptions);
|
| 371 |
+
}
|
| 372 |
+
}, [stableSubscriptionOptions]);
|
| 373 |
+
const subscriptionOptionsRef = useRef3(stableSubscriptionOptions);
|
| 374 |
+
usePossiblyImmediateEffect(() => {
|
| 375 |
+
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
| 376 |
+
}, [stableSubscriptionOptions]);
|
| 377 |
+
const trigger = useCallback(function(arg2, preferCacheValue = false) {
|
| 378 |
+
let promise;
|
| 379 |
+
batch(() => {
|
| 380 |
+
promiseRef.current?.unsubscribe();
|
| 381 |
+
promiseRef.current = promise = dispatch(initiate(arg2, {
|
| 382 |
+
subscriptionOptions: subscriptionOptionsRef.current,
|
| 383 |
+
forceRefetch: !preferCacheValue
|
| 384 |
+
}));
|
| 385 |
+
setArg(arg2);
|
| 386 |
+
});
|
| 387 |
+
return promise;
|
| 388 |
+
}, [dispatch, initiate]);
|
| 389 |
+
const reset = useCallback(() => {
|
| 390 |
+
if (promiseRef.current?.queryCacheKey) {
|
| 391 |
+
dispatch(api.internalActions.removeQueryResult({
|
| 392 |
+
queryCacheKey: promiseRef.current?.queryCacheKey
|
| 393 |
+
}));
|
| 394 |
+
}
|
| 395 |
+
}, [dispatch]);
|
| 396 |
+
useEffect3(() => {
|
| 397 |
+
return () => {
|
| 398 |
+
promiseRef?.current?.unsubscribe();
|
| 399 |
+
};
|
| 400 |
+
}, []);
|
| 401 |
+
useEffect3(() => {
|
| 402 |
+
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
| 403 |
+
trigger(arg, true);
|
| 404 |
+
}
|
| 405 |
+
}, [arg, trigger]);
|
| 406 |
+
return useMemo2(() => [trigger, arg, {
|
| 407 |
+
reset
|
| 408 |
+
}], [trigger, arg, reset]);
|
| 409 |
+
};
|
| 410 |
+
const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
|
| 411 |
+
return {
|
| 412 |
+
useQueryState,
|
| 413 |
+
useQuerySubscription,
|
| 414 |
+
useLazyQuerySubscription,
|
| 415 |
+
useLazyQuery(options) {
|
| 416 |
+
const [trigger, arg, {
|
| 417 |
+
reset
|
| 418 |
+
}] = useLazyQuerySubscription(options);
|
| 419 |
+
const queryStateResults = useQueryState(arg, {
|
| 420 |
+
...options,
|
| 421 |
+
skip: arg === UNINITIALIZED_VALUE
|
| 422 |
+
});
|
| 423 |
+
const info = useMemo2(() => ({
|
| 424 |
+
lastArg: arg
|
| 425 |
+
}), [arg]);
|
| 426 |
+
return useMemo2(() => [trigger, {
|
| 427 |
+
...queryStateResults,
|
| 428 |
+
reset
|
| 429 |
+
}, info], [trigger, queryStateResults, reset, info]);
|
| 430 |
+
},
|
| 431 |
+
useQuery(arg, options) {
|
| 432 |
+
const querySubscriptionResults = useQuerySubscription(arg, options);
|
| 433 |
+
const queryStateResults = useQueryState(arg, {
|
| 434 |
+
selectFromResult: arg === skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
| 435 |
+
...options
|
| 436 |
+
});
|
| 437 |
+
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
| 438 |
+
useDebugValue(debugValue);
|
| 439 |
+
return useMemo2(() => ({
|
| 440 |
+
...queryStateResults,
|
| 441 |
+
...querySubscriptionResults
|
| 442 |
+
}), [queryStateResults, querySubscriptionResults]);
|
| 443 |
+
}
|
| 444 |
+
};
|
| 445 |
+
}
|
| 446 |
+
function buildInfiniteQueryHooks(endpointName) {
|
| 447 |
+
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
| 448 |
+
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
| 449 |
+
const subscriptionOptionsRef = useRef3(stableSubscriptionOptions);
|
| 450 |
+
usePossiblyImmediateEffect(() => {
|
| 451 |
+
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
| 452 |
+
}, [stableSubscriptionOptions]);
|
| 453 |
+
const trigger = useCallback(function(arg2, direction) {
|
| 454 |
+
let promise;
|
| 455 |
+
batch(() => {
|
| 456 |
+
promiseRef.current?.unsubscribe();
|
| 457 |
+
promiseRef.current = promise = dispatch(initiate(arg2, {
|
| 458 |
+
subscriptionOptions: subscriptionOptionsRef.current,
|
| 459 |
+
direction
|
| 460 |
+
}));
|
| 461 |
+
});
|
| 462 |
+
return promise;
|
| 463 |
+
}, [promiseRef, dispatch, initiate]);
|
| 464 |
+
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
| 465 |
+
const stableArg = useStableQueryArgs(
|
| 466 |
+
options.skip ? skipToken : arg,
|
| 467 |
+
// Even if the user provided a per-endpoint `serializeQueryArgs` with
|
| 468 |
+
// a consistent return value, _here_ we want to use the default behavior
|
| 469 |
+
// so we can tell if _anything_ actually changed. Otherwise, we can end up
|
| 470 |
+
// with a case where the query args did change but the serialization doesn't,
|
| 471 |
+
// and then we never try to initiate a refetch.
|
| 472 |
+
defaultSerializeQueryArgs,
|
| 473 |
+
context.endpointDefinitions[endpointName],
|
| 474 |
+
endpointName
|
| 475 |
+
);
|
| 476 |
+
const refetch = useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
|
| 477 |
+
return useMemo2(() => {
|
| 478 |
+
const fetchNextPage = () => {
|
| 479 |
+
return trigger(stableArg, "forward");
|
| 480 |
+
};
|
| 481 |
+
const fetchPreviousPage = () => {
|
| 482 |
+
return trigger(stableArg, "backward");
|
| 483 |
+
};
|
| 484 |
+
return {
|
| 485 |
+
trigger,
|
| 486 |
+
/**
|
| 487 |
+
* A method to manually refetch data for the query
|
| 488 |
+
*/
|
| 489 |
+
refetch,
|
| 490 |
+
fetchNextPage,
|
| 491 |
+
fetchPreviousPage
|
| 492 |
+
};
|
| 493 |
+
}, [refetch, trigger, stableArg]);
|
| 494 |
+
};
|
| 495 |
+
const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
|
| 496 |
+
return {
|
| 497 |
+
useInfiniteQueryState,
|
| 498 |
+
useInfiniteQuerySubscription,
|
| 499 |
+
useInfiniteQuery(arg, options) {
|
| 500 |
+
const {
|
| 501 |
+
refetch,
|
| 502 |
+
fetchNextPage,
|
| 503 |
+
fetchPreviousPage
|
| 504 |
+
} = useInfiniteQuerySubscription(arg, options);
|
| 505 |
+
const queryStateResults = useInfiniteQueryState(arg, {
|
| 506 |
+
selectFromResult: arg === skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
|
| 507 |
+
...options
|
| 508 |
+
});
|
| 509 |
+
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
| 510 |
+
useDebugValue(debugValue);
|
| 511 |
+
return useMemo2(() => ({
|
| 512 |
+
...queryStateResults,
|
| 513 |
+
fetchNextPage,
|
| 514 |
+
fetchPreviousPage,
|
| 515 |
+
refetch
|
| 516 |
+
}), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
|
| 517 |
+
}
|
| 518 |
+
};
|
| 519 |
+
}
|
| 520 |
+
function buildMutationHook(name) {
|
| 521 |
+
return ({
|
| 522 |
+
selectFromResult,
|
| 523 |
+
fixedCacheKey
|
| 524 |
+
} = {}) => {
|
| 525 |
+
const {
|
| 526 |
+
select,
|
| 527 |
+
initiate
|
| 528 |
+
} = api.endpoints[name];
|
| 529 |
+
const dispatch = useDispatch();
|
| 530 |
+
const [promise, setPromise] = useState();
|
| 531 |
+
useEffect3(() => () => {
|
| 532 |
+
if (!promise?.arg.fixedCacheKey) {
|
| 533 |
+
promise?.reset();
|
| 534 |
+
}
|
| 535 |
+
}, [promise]);
|
| 536 |
+
const triggerMutation = useCallback(function(arg) {
|
| 537 |
+
const promise2 = dispatch(initiate(arg, {
|
| 538 |
+
fixedCacheKey
|
| 539 |
+
}));
|
| 540 |
+
setPromise(promise2);
|
| 541 |
+
return promise2;
|
| 542 |
+
}, [dispatch, initiate, fixedCacheKey]);
|
| 543 |
+
const {
|
| 544 |
+
requestId
|
| 545 |
+
} = promise || {};
|
| 546 |
+
const selectDefaultResult = useMemo2(() => select({
|
| 547 |
+
fixedCacheKey,
|
| 548 |
+
requestId: promise?.requestId
|
| 549 |
+
}), [fixedCacheKey, promise, select]);
|
| 550 |
+
const mutationSelector = useMemo2(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
| 551 |
+
const currentState = useSelector(mutationSelector, shallowEqual2);
|
| 552 |
+
const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : void 0;
|
| 553 |
+
const reset = useCallback(() => {
|
| 554 |
+
batch(() => {
|
| 555 |
+
if (promise) {
|
| 556 |
+
setPromise(void 0);
|
| 557 |
+
}
|
| 558 |
+
if (fixedCacheKey) {
|
| 559 |
+
dispatch(api.internalActions.removeMutationResult({
|
| 560 |
+
requestId,
|
| 561 |
+
fixedCacheKey
|
| 562 |
+
}));
|
| 563 |
+
}
|
| 564 |
+
});
|
| 565 |
+
}, [dispatch, fixedCacheKey, promise, requestId]);
|
| 566 |
+
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
| 567 |
+
useDebugValue(debugValue);
|
| 568 |
+
const finalState = useMemo2(() => ({
|
| 569 |
+
...currentState,
|
| 570 |
+
originalArgs,
|
| 571 |
+
reset
|
| 572 |
+
}), [currentState, originalArgs, reset]);
|
| 573 |
+
return useMemo2(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
| 574 |
+
};
|
| 575 |
+
}
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
// src/query/react/module.ts
|
| 579 |
+
var reactHooksModuleName = /* @__PURE__ */ Symbol();
|
| 580 |
+
var reactHooksModule = ({
|
| 581 |
+
batch = rrBatch,
|
| 582 |
+
hooks = {
|
| 583 |
+
useDispatch: rrUseDispatch,
|
| 584 |
+
useSelector: rrUseSelector,
|
| 585 |
+
useStore: rrUseStore
|
| 586 |
+
},
|
| 587 |
+
createSelector = _createSelector,
|
| 588 |
+
unstable__sideEffectsInRender = false,
|
| 589 |
+
...rest
|
| 590 |
+
} = {}) => {
|
| 591 |
+
if (process.env.NODE_ENV !== "production") {
|
| 592 |
+
const hookNames = ["useDispatch", "useSelector", "useStore"];
|
| 593 |
+
let warned = false;
|
| 594 |
+
for (const hookName of hookNames) {
|
| 595 |
+
if (countObjectKeys(rest) > 0) {
|
| 596 |
+
if (rest[hookName]) {
|
| 597 |
+
if (!warned) {
|
| 598 |
+
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 } })`");
|
| 599 |
+
warned = true;
|
| 600 |
+
}
|
| 601 |
+
}
|
| 602 |
+
hooks[hookName] = rest[hookName];
|
| 603 |
+
}
|
| 604 |
+
if (typeof hooks[hookName] !== "function") {
|
| 605 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage3(36) : `When using custom hooks for context, all ${hookNames.length} hooks need to be provided: ${hookNames.join(", ")}.
|
| 606 |
+
Hook ${hookName} was either not provided or not a function.`);
|
| 607 |
+
}
|
| 608 |
+
}
|
| 609 |
+
}
|
| 610 |
+
return {
|
| 611 |
+
name: reactHooksModuleName,
|
| 612 |
+
init(api, {
|
| 613 |
+
serializeQueryArgs
|
| 614 |
+
}, context) {
|
| 615 |
+
const anyApi = api;
|
| 616 |
+
const {
|
| 617 |
+
buildQueryHooks,
|
| 618 |
+
buildInfiniteQueryHooks,
|
| 619 |
+
buildMutationHook,
|
| 620 |
+
usePrefetch
|
| 621 |
+
} = buildHooks({
|
| 622 |
+
api,
|
| 623 |
+
moduleOptions: {
|
| 624 |
+
batch,
|
| 625 |
+
hooks,
|
| 626 |
+
unstable__sideEffectsInRender,
|
| 627 |
+
createSelector
|
| 628 |
+
},
|
| 629 |
+
serializeQueryArgs,
|
| 630 |
+
context
|
| 631 |
+
});
|
| 632 |
+
safeAssign(anyApi, {
|
| 633 |
+
usePrefetch
|
| 634 |
+
});
|
| 635 |
+
safeAssign(context, {
|
| 636 |
+
batch
|
| 637 |
+
});
|
| 638 |
+
return {
|
| 639 |
+
injectEndpoint(endpointName, definition) {
|
| 640 |
+
if (isQueryDefinition(definition)) {
|
| 641 |
+
const {
|
| 642 |
+
useQuery,
|
| 643 |
+
useLazyQuery,
|
| 644 |
+
useLazyQuerySubscription,
|
| 645 |
+
useQueryState,
|
| 646 |
+
useQuerySubscription
|
| 647 |
+
} = buildQueryHooks(endpointName);
|
| 648 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 649 |
+
useQuery,
|
| 650 |
+
useLazyQuery,
|
| 651 |
+
useLazyQuerySubscription,
|
| 652 |
+
useQueryState,
|
| 653 |
+
useQuerySubscription
|
| 654 |
+
});
|
| 655 |
+
api[`use${capitalize(endpointName)}Query`] = useQuery;
|
| 656 |
+
api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
|
| 657 |
+
}
|
| 658 |
+
if (isMutationDefinition(definition)) {
|
| 659 |
+
const useMutation = buildMutationHook(endpointName);
|
| 660 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 661 |
+
useMutation
|
| 662 |
+
});
|
| 663 |
+
api[`use${capitalize(endpointName)}Mutation`] = useMutation;
|
| 664 |
+
} else if (isInfiniteQueryDefinition(definition)) {
|
| 665 |
+
const {
|
| 666 |
+
useInfiniteQuery,
|
| 667 |
+
useInfiniteQuerySubscription,
|
| 668 |
+
useInfiniteQueryState
|
| 669 |
+
} = buildInfiniteQueryHooks(endpointName);
|
| 670 |
+
safeAssign(anyApi.endpoints[endpointName], {
|
| 671 |
+
useInfiniteQuery,
|
| 672 |
+
useInfiniteQuerySubscription,
|
| 673 |
+
useInfiniteQueryState
|
| 674 |
+
});
|
| 675 |
+
api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
|
| 676 |
+
}
|
| 677 |
+
}
|
| 678 |
+
};
|
| 679 |
+
}
|
| 680 |
+
};
|
| 681 |
+
};
|
| 682 |
+
|
| 683 |
+
// src/query/react/index.ts
|
| 684 |
+
export * from "@reduxjs/toolkit/query";
|
| 685 |
+
|
| 686 |
+
// src/query/react/ApiProvider.tsx
|
| 687 |
+
import { configureStore, formatProdErrorMessage as _formatProdErrorMessage4 } from "@reduxjs/toolkit";
|
| 688 |
+
import { useContext } from "react";
|
| 689 |
+
import { useEffect as useEffect4 } from "react";
|
| 690 |
+
import * as React from "react";
|
| 691 |
+
import { Provider, ReactReduxContext } from "react-redux";
|
| 692 |
+
import { setupListeners } from "@reduxjs/toolkit/query";
|
| 693 |
+
function ApiProvider(props) {
|
| 694 |
+
const context = props.context || ReactReduxContext;
|
| 695 |
+
const existingContext = useContext(context);
|
| 696 |
+
if (existingContext) {
|
| 697 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage4(35) : "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.");
|
| 698 |
+
}
|
| 699 |
+
const [store] = React.useState(() => configureStore({
|
| 700 |
+
reducer: {
|
| 701 |
+
[props.api.reducerPath]: props.api.reducer
|
| 702 |
+
},
|
| 703 |
+
middleware: (gDM) => gDM().concat(props.api.middleware)
|
| 704 |
+
}));
|
| 705 |
+
useEffect4(() => props.setupListeners === false ? void 0 : setupListeners(store.dispatch, props.setupListeners), [props.setupListeners, store.dispatch]);
|
| 706 |
+
return /* @__PURE__ */ React.createElement(Provider, { store, context }, props.children);
|
| 707 |
+
}
|
| 708 |
+
|
| 709 |
+
// src/query/react/index.ts
|
| 710 |
+
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
| 711 |
+
export {
|
| 712 |
+
ApiProvider,
|
| 713 |
+
UNINITIALIZED_VALUE,
|
| 714 |
+
createApi,
|
| 715 |
+
reactHooksModule,
|
| 716 |
+
reactHooksModuleName
|
| 717 |
+
};
|
| 718 |
+
//# sourceMappingURL=rtk-query-react.modern.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/react/rtk-query-react.modern.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Ue=(y=>(y.uninitialized="uninitialized",y.pending="pending",y.fulfilled="fulfilled",y.rejected="rejected",y))(Ue||{});function Le(e){return{status:e,isUninitialized:e==="uninitialized",isLoading:e==="pending",isSuccess:e==="fulfilled",isError:e==="rejected"}}import{createAction as X,createSlice as ae,createSelector as Ye,createAsyncThunk as je,combineReducers as Xe,createNextState as Se,isAnyOf as oe,isAllOf as Pe,isAction as Ze,isPending as Ie,isRejected as fe,isFulfilled as W,isRejectedWithValue as me,isAsyncThunkAction as He,prepareAutoBatched as ge,SHOULD_AUTOBATCH as ke,isPlainObject as te,nanoid as Be}from"@reduxjs/toolkit";var et=te;function Me(e,n){if(e===n||!(et(e)&&et(n)||Array.isArray(e)&&Array.isArray(n)))return n;let d=Object.keys(n),g=Object.keys(e),y=d.length===g.length,x=Array.isArray(n)?[]:{};for(let T of d)x[T]=Me(e[T],n[T]),y&&(y=e[T]===x[T]);return y?e:x}function J(e){let n=0;for(let d in e)n++;return n}var _e=e=>[].concat(...e);function tt(e){return new RegExp("(^|:)//").test(e)}function nt(){return typeof document>"u"?!0:document.visibilityState!=="hidden"}function se(e){return e!=null}function rt(){return typeof navigator>"u"||navigator.onLine===void 0?!0:navigator.onLine}var Ct=e=>e.replace(/\/$/,""),Ft=e=>e.replace(/^\//,"");function it(e,n){if(!e)return n;if(!n)return e;if(tt(n))return n;let d=e.endsWith("/")||!n.startsWith("?")?"/":"";return e=Ct(e),n=Ft(n),`${e}${d}${n}`}function at(e,n,d){return e.has(n)?e.get(n):e.set(n,d).get(n)}var ot=(...e)=>fetch(...e),vt=e=>e.status>=200&&e.status<=299,Ot=e=>/ion\/(vnd\.api\+)?json/.test(e.get("content-type")||"");function st(e){if(!te(e))return e;let n={...e};for(let[d,g]of Object.entries(n))g===void 0&&delete n[d];return n}function Nt({baseUrl:e,prepareHeaders:n=h=>h,fetchFn:d=ot,paramsSerializer:g,isJsonContentType:y=Ot,jsonContentType:x="application/json",jsonReplacer:T,timeout:k,responseHandler:w,validateStatus:A,...P}={}){return typeof fetch>"u"&&d===ot&&console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments."),async(R,a,f)=>{let{getState:B,extra:p,endpoint:o,forced:S,type:c}=a,u,{url:m,headers:D=new Headers(P.headers),params:b=void 0,responseHandler:I=w??"json",validateStatus:Q=A??vt,timeout:s=k,...t}=typeof R=="string"?{url:R}:R,r,i=a.signal;s&&(r=new AbortController,a.signal.addEventListener("abort",r.abort),i=r.signal);let l={...P,signal:i,...t};D=new Headers(st(D)),l.headers=await n(D,{getState:B,arg:R,extra:p,endpoint:o,forced:S,type:c,extraOptions:f})||D;let E=N=>typeof N=="object"&&(te(N)||Array.isArray(N)||typeof N.toJSON=="function");if(!l.headers.has("content-type")&&E(l.body)&&l.headers.set("content-type",x),E(l.body)&&y(l.headers)&&(l.body=JSON.stringify(l.body,T)),b){let N=~m.indexOf("?")?"&":"?",F=g?g(b):new URLSearchParams(st(b));m+=N+F}m=it(e,m);let v=new Request(m,l);u={request:new Request(m,l)};let C,M=!1,K=r&&setTimeout(()=>{M=!0,r.abort()},s);try{C=await d(v)}catch(N){return{error:{status:M?"TIMEOUT_ERROR":"FETCH_ERROR",error:String(N)},meta:u}}finally{K&&clearTimeout(K),r?.signal.removeEventListener("abort",r.abort)}let j=C.clone();u.response=j;let z,L="";try{let N;if(await Promise.all([h(C,I).then(F=>z=F,F=>N=F),j.text().then(F=>L=F,()=>{})]),N)throw N}catch(N){return{error:{status:"PARSING_ERROR",originalStatus:C.status,data:L,error:String(N)},meta:u}}return Q(C,z)?{data:z,meta:u}:{error:{status:C.status,data:z},meta:u}};async function h(R,a){if(typeof a=="function")return a(R);if(a==="content-type"&&(a=y(R.headers)?"json":"text"),a==="json"){let f=await R.text();return f.length?JSON.parse(f):null}return R.text()}}var G=class{constructor(n,d=void 0){this.value=n;this.meta=d}};async function qt(e=0,n=5){let d=Math.min(e,n),g=~~((Math.random()+.4)*(300<<d));await new Promise(y=>setTimeout(x=>y(x),g))}function Kt(e,n){throw Object.assign(new G({error:e,meta:n}),{throwImmediately:!0})}var ut={},Ut=(e,n)=>async(d,g,y)=>{let x=[5,(n||ut).maxRetries,(y||ut).maxRetries].filter(P=>P!==void 0),[T]=x.slice(-1),w={maxRetries:T,backoff:qt,retryCondition:(P,h,{attempt:R})=>R<=T,...n,...y},A=0;for(;;)try{let P=await e(d,g,y);if(P.error)throw new G(P);return P}catch(P){if(A++,P.throwImmediately){if(P instanceof G)return P.value;throw P}if(P instanceof G&&!w.retryCondition(P.value.error,d,{attempt:A,baseQueryApi:g,extraOptions:y}))return P.value;await w.backoff(A,w.maxRetries)}},Lt=Object.assign(Ut,{fail:Kt});var ne=X("__rtkq/focused"),Qe=X("__rtkq/unfocused"),re=X("__rtkq/online"),Te=X("__rtkq/offline"),Ve=!1;function jt(e,n){function d(){let g=()=>e(ne()),y=()=>e(Qe()),x=()=>e(re()),T=()=>e(Te()),k=()=>{window.document.visibilityState==="visible"?g():y()};return Ve||typeof window<"u"&&window.addEventListener&&(window.addEventListener("visibilitychange",k,!1),window.addEventListener("focus",g,!1),window.addEventListener("online",x,!1),window.addEventListener("offline",T,!1),Ve=!0),()=>{window.removeEventListener("focus",g),window.removeEventListener("visibilitychange",k),window.removeEventListener("online",x),window.removeEventListener("offline",T),Ve=!1}}return n?n(e,{onFocus:ne,onFocusLost:Qe,onOffline:Te,onOnline:re}):d()}function ue(e){return e.type==="query"}function yt(e){return e.type==="mutation"}function ye(e){return e.type==="infinitequery"}function he(e){return ue(e)||ye(e)}function xe(e,n,d,g,y,x){return Ht(e)?e(n,d,g,y).filter(se).map(we).map(x):Array.isArray(e)?e.map(we).map(x):[]}function Ht(e){return typeof e=="function"}function we(e){return typeof e=="string"?{type:e}:e}import{isDraftable as Vt,produceWithPatches as zt}from"immer";import"@reduxjs/toolkit";function dt(e,n){return e.catch(n)}var Ae=Symbol("forceQueryFn"),De=e=>typeof e[Ae]=="function";function pt({serializeQueryArgs:e,queryThunk:n,infiniteQueryThunk:d,mutationThunk:g,api:y,context:x}){let T=new Map,k=new Map,{unsubscribeQueryResult:w,removeMutationResult:A,updateSubscriptionOptions:P}=y.internalActions;return{buildInitiateQuery:o,buildInitiateInfiniteQuery:S,buildInitiateMutation:c,getRunningQueryThunk:h,getRunningMutationThunk:R,getRunningQueriesThunk:a,getRunningMutationsThunk:f};function h(u,m){return D=>{let b=x.endpointDefinitions[u],I=e({queryArgs:m,endpointDefinition:b,endpointName:u});return T.get(D)?.[I]}}function R(u,m){return D=>k.get(D)?.[m]}function a(){return u=>Object.values(T.get(u)||{}).filter(se)}function f(){return u=>Object.values(k.get(u)||{}).filter(se)}function B(u){}function p(u,m){let D=(b,{subscribe:I=!0,forceRefetch:Q,subscriptionOptions:s,[Ae]:t,...r}={})=>(i,l)=>{let E=e({queryArgs:b,endpointDefinition:m,endpointName:u}),v,O={...r,type:"query",subscribe:I,forceRefetch:Q,subscriptionOptions:s,endpointName:u,originalArgs:b,queryCacheKey:E,[Ae]:t};if(ue(m))v=n(O);else{let{direction:H,initialPageParam:q}=r;v=d({...O,direction:H,initialPageParam:q})}let C=y.endpoints[u].select(b),M=i(v),K=C(l());let{requestId:j,abort:z}=M,L=K.requestId!==j,N=T.get(i)?.[E],F=()=>C(l()),_=Object.assign(t?M.then(F):L&&!N?Promise.resolve(K):Promise.all([N,M]).then(F),{arg:b,requestId:j,subscriptionOptions:s,queryCacheKey:E,abort:z,async unwrap(){let H=await _;if(H.isError)throw H.error;return H.data},refetch:()=>i(D(b,{subscribe:!1,forceRefetch:!0})),unsubscribe(){I&&i(w({queryCacheKey:E,requestId:j}))},updateSubscriptionOptions(H){_.subscriptionOptions=H,i(P({endpointName:u,requestId:j,queryCacheKey:E,options:H}))}});if(!N&&!L&&!t){let H=at(T,i,{});H[E]=_,_.then(()=>{delete H[E],J(H)||T.delete(i)})}return _};return D}function o(u,m){return p(u,m)}function S(u,m){return p(u,m)}function c(u){return(m,{track:D=!0,fixedCacheKey:b}={})=>(I,Q)=>{let s=g({type:"mutation",endpointName:u,originalArgs:m,track:D,fixedCacheKey:b}),t=I(s);let{requestId:r,abort:i,unwrap:l}=t,E=dt(t.unwrap().then(M=>({data:M})),M=>({error:M})),v=()=>{I(A({requestId:r,fixedCacheKey:b}))},O=Object.assign(E,{arg:t.arg,requestId:r,abort:i,unwrap:l,reset:v}),C=k.get(I)||{};return k.set(I,C),C[r]=O,O.then(()=>{delete C[r],J(C)||k.delete(I)}),b&&(C[b]=O,O.then(()=>{C[b]===O&&(delete C[b],J(C)||k.delete(I))})),O}}}import{SchemaError as _t}from"@standard-schema/utils";var Re=class extends _t{constructor(d,g,y,x){super(d);this.value=g;this.schemaName=y;this._bqMeta=x}};async function ie(e,n,d,g){let y=await e["~standard"].validate(n);if(y.issues)throw new Re(y.issues,n,d,g);return y.value}function Wt(e){return e}var be=(e={})=>({...e,[ke]:!0});function ct({reducerPath:e,baseQuery:n,context:{endpointDefinitions:d},serializeQueryArgs:g,api:y,assertTagType:x,selectors:T,onSchemaFailure:k,catchSchemaFailure:w,skipSchemaValidation:A}){let P=(t,r,i,l)=>(E,v)=>{let O=d[t],C=g({queryArgs:r,endpointDefinition:O,endpointName:t});if(E(y.internalActions.queryResultPatched({queryCacheKey:C,patches:i})),!l)return;let M=y.endpoints[t].select(r)(v()),K=xe(O.providesTags,M.data,void 0,r,{},x);E(y.internalActions.updateProvidedBy([{queryCacheKey:C,providedTags:K}]))};function h(t,r,i=0){let l=[r,...t];return i&&l.length>i?l.slice(0,-1):l}function R(t,r,i=0){let l=[...t,r];return i&&l.length>i?l.slice(1):l}let a=(t,r,i,l=!0)=>(E,v)=>{let C=y.endpoints[t].select(r)(v()),M={patches:[],inversePatches:[],undo:()=>E(y.util.patchQueryData(t,r,M.inversePatches,l))};if(C.status==="uninitialized")return M;let K;if("data"in C)if(Vt(C.data)){let[j,z,L]=zt(C.data,i);M.patches.push(...z),M.inversePatches.push(...L),K=j}else K=i(C.data),M.patches.push({op:"replace",path:[],value:K}),M.inversePatches.push({op:"replace",path:[],value:C.data});return M.patches.length===0||E(y.util.patchQueryData(t,r,M.patches,l)),M},f=(t,r,i)=>l=>l(y.endpoints[t].initiate(r,{subscribe:!1,forceRefetch:!0,[Ae]:()=>({data:i})})),B=(t,r)=>t.query&&t[r]?t[r]:Wt,p=async(t,{signal:r,abort:i,rejectWithValue:l,fulfillWithValue:E,dispatch:v,getState:O,extra:C})=>{let M=d[t.endpointName],{metaSchema:K,skipSchemaValidation:j=A}=M;try{let z=B(M,"transformResponse"),L={signal:r,abort:i,dispatch:v,getState:O,extra:C,endpoint:t.endpointName,type:t.type,forced:t.type==="query"?o(t,O()):void 0,queryCacheKey:t.type==="query"?t.queryCacheKey:void 0},N=t.type==="query"?t[Ae]:void 0,F,_=async(q,U,V,pe)=>{if(U==null&&q.pages.length)return Promise.resolve({data:q});let Z={queryArg:t.originalArgs,pageParam:U},ce=await H(Z),$=pe?h:R;return{data:{pages:$(q.pages,ce.data,V),pageParams:$(q.pageParams,U,V)},meta:ce.meta}};async function H(q){let U,{extraOptions:V,argSchema:pe,rawResponseSchema:Z,responseSchema:ce}=M;if(pe&&!j&&(q=await ie(pe,q,"argSchema",{})),N?U=N():M.query?U=await n(M.query(q),L,V):U=await M.queryFn(q,L,V,le=>n(le,L,V)),U.error)throw new G(U.error,U.meta);let{data:$}=U;Z&&!j&&($=await ie(Z,U.data,"rawResponseSchema",U.meta));let ee=await z($,U.meta,q);return ce&&!j&&(ee=await ie(ce,ee,"responseSchema",U.meta)),{...U,data:ee}}if(t.type==="query"&&"infiniteQueryOptions"in M){let{infiniteQueryOptions:q}=M,{maxPages:U=1/0}=q,V,pe={pages:[],pageParams:[]},Z=T.selectQueryEntry(O(),t.queryCacheKey)?.data,$=o(t,O())&&!t.direction||!Z?pe:Z;if("direction"in t&&t.direction&&$.pages.length){let ee=t.direction==="backward",Ee=(ee?ze:Ce)(q,$,t.originalArgs);V=await _($,Ee,U,ee)}else{let{initialPageParam:ee=q.initialPageParam}=t,le=Z?.pageParams??[],Ee=le[0]??ee,Je=le.length;V=await _($,Ee,U),N&&(V={data:V.data.pages[0]});for(let Ge=1;Ge<Je;Ge++){let wt=Ce(q,V.data,t.originalArgs);V=await _(V.data,wt,U)}}F=V}else F=await H(t.originalArgs);return K&&!j&&F.meta&&(F.meta=await ie(K,F.meta,"metaSchema",F.meta)),E(F.data,be({fulfilledTimeStamp:Date.now(),baseQueryMeta:F.meta}))}catch(z){let L=z;if(L instanceof G){let N=B(M,"transformErrorResponse"),{rawErrorResponseSchema:F,errorResponseSchema:_}=M,{value:H,meta:q}=L;try{F&&!j&&(H=await ie(F,H,"rawErrorResponseSchema",q)),K&&!j&&(q=await ie(K,q,"metaSchema",q));let U=await N(H,q,t.originalArgs);return _&&!j&&(U=await ie(_,U,"errorResponseSchema",q)),l(U,be({baseQueryMeta:q}))}catch(U){L=U}}try{if(L instanceof Re){let N={endpoint:t.endpointName,arg:t.originalArgs,type:t.type,queryCacheKey:t.type==="query"?t.queryCacheKey:void 0};M.onSchemaFailure?.(L,N),k?.(L,N);let{catchSchemaFailure:F=w}=M;if(F)return l(F(L,N),be({baseQueryMeta:L._bqMeta}))}}catch(N){L=N}throw console.error(L),L}};function o(t,r){let i=T.selectQueryEntry(r,t.queryCacheKey),l=T.selectConfig(r).refetchOnMountOrArgChange,E=i?.fulfilledTimeStamp,v=t.forceRefetch??(t.subscribe&&l);return v?v===!0||(Number(new Date)-Number(E))/1e3>=v:!1}let S=()=>je(`${e}/executeQuery`,p,{getPendingMeta({arg:r}){let i=d[r.endpointName];return be({startedTimeStamp:Date.now(),...ye(i)?{direction:r.direction}:{}})},condition(r,{getState:i}){let l=i(),E=T.selectQueryEntry(l,r.queryCacheKey),v=E?.fulfilledTimeStamp,O=r.originalArgs,C=E?.originalArgs,M=d[r.endpointName],K=r.direction;return De(r)?!0:E?.status==="pending"?!1:o(r,l)||ue(M)&&M?.forceRefetch?.({currentArg:O,previousArg:C,endpointState:E,state:l})?!0:!(v&&!K)},dispatchConditionRejection:!0}),c=S(),u=S(),m=je(`${e}/executeMutation`,p,{getPendingMeta(){return be({startedTimeStamp:Date.now()})}}),D=t=>"force"in t,b=t=>"ifOlderThan"in t,I=(t,r,i)=>(l,E)=>{let v=D(i)&&i.force,O=b(i)&&i.ifOlderThan,C=(K=!0)=>{let j={forceRefetch:K,isPrefetch:!0};return y.endpoints[t].initiate(r,j)},M=y.endpoints[t].select(r)(E());if(v)l(C());else if(O){let K=M?.fulfilledTimeStamp;if(!K){l(C());return}(Number(new Date)-Number(new Date(K)))/1e3>=O&&l(C())}else l(C(!1))};function Q(t){return r=>r?.meta?.arg?.endpointName===t}function s(t,r){return{matchPending:Pe(Ie(t),Q(r)),matchFulfilled:Pe(W(t),Q(r)),matchRejected:Pe(fe(t),Q(r))}}return{queryThunk:c,mutationThunk:m,infiniteQueryThunk:u,prefetch:I,updateQueryData:a,upsertQueryData:f,patchQueryData:P,buildMatchThunkActions:s}}function Ce(e,{pages:n,pageParams:d},g){let y=n.length-1;return e.getNextPageParam(n[y],n,d[y],d,g)}function ze(e,{pages:n,pageParams:d},g){return e.getPreviousPageParam?.(n[0],n,d[0],d,g)}function Fe(e,n,d,g){return xe(d[e.meta.arg.endpointName][n],W(e)?e.payload:void 0,me(e)?e.payload:void 0,e.meta.arg.originalArgs,"baseQueryMeta"in e.meta?e.meta.baseQueryMeta:void 0,g)}import{isDraft as $t}from"immer";import{applyPatches as lt,original as Jt}from"immer";function ve(e,n,d){let g=e[n];g&&d(g)}function de(e){return("arg"in e?e.arg.fixedCacheKey:e.fixedCacheKey)??e.requestId}function ft(e,n,d){let g=e[de(n)];g&&d(g)}var Oe={};function mt({reducerPath:e,queryThunk:n,mutationThunk:d,serializeQueryArgs:g,context:{endpointDefinitions:y,apiUid:x,extractRehydrationInfo:T,hasRehydrationInfo:k},assertTagType:w,config:A}){let P=X(`${e}/resetApiState`);function h(Q,s,t,r){Q[s.queryCacheKey]??={status:"uninitialized",endpointName:s.endpointName},ve(Q,s.queryCacheKey,i=>{i.status="pending",i.requestId=t&&i.requestId?i.requestId:r.requestId,s.originalArgs!==void 0&&(i.originalArgs=s.originalArgs),i.startedTimeStamp=r.startedTimeStamp;let l=y[r.arg.endpointName];ye(l)&&"direction"in s&&(i.direction=s.direction)})}function R(Q,s,t,r){ve(Q,s.arg.queryCacheKey,i=>{if(i.requestId!==s.requestId&&!r)return;let{merge:l}=y[s.arg.endpointName];if(i.status="fulfilled",l)if(i.data!==void 0){let{fulfilledTimeStamp:E,arg:v,baseQueryMeta:O,requestId:C}=s,M=Se(i.data,K=>l(K,t,{arg:v.originalArgs,baseQueryMeta:O,fulfilledTimeStamp:E,requestId:C}));i.data=M}else i.data=t;else i.data=y[s.arg.endpointName].structuralSharing??!0?Me($t(i.data)?Jt(i.data):i.data,t):t;delete i.error,i.fulfilledTimeStamp=s.fulfilledTimeStamp})}let a=ae({name:`${e}/queries`,initialState:Oe,reducers:{removeQueryResult:{reducer(Q,{payload:{queryCacheKey:s}}){delete Q[s]},prepare:ge()},cacheEntriesUpserted:{reducer(Q,s){for(let t of s.payload){let{queryDescription:r,value:i}=t;h(Q,r,!0,{arg:r,requestId:s.meta.requestId,startedTimeStamp:s.meta.timestamp}),R(Q,{arg:r,requestId:s.meta.requestId,fulfilledTimeStamp:s.meta.timestamp,baseQueryMeta:{}},i,!0)}},prepare:Q=>({payload:Q.map(r=>{let{endpointName:i,arg:l,value:E}=r,v=y[i];return{queryDescription:{type:"query",endpointName:i,originalArgs:r.arg,queryCacheKey:g({queryArgs:l,endpointDefinition:v,endpointName:i})},value:E}}),meta:{[ke]:!0,requestId:Be(),timestamp:Date.now()}})},queryResultPatched:{reducer(Q,{payload:{queryCacheKey:s,patches:t}}){ve(Q,s,r=>{r.data=lt(r.data,t.concat())})},prepare:ge()}},extraReducers(Q){Q.addCase(n.pending,(s,{meta:t,meta:{arg:r}})=>{let i=De(r);h(s,r,i,t)}).addCase(n.fulfilled,(s,{meta:t,payload:r})=>{let i=De(t.arg);R(s,t,r,i)}).addCase(n.rejected,(s,{meta:{condition:t,arg:r,requestId:i},error:l,payload:E})=>{ve(s,r.queryCacheKey,v=>{if(!t){if(v.requestId!==i)return;v.status="rejected",v.error=E??l}})}).addMatcher(k,(s,t)=>{let{queries:r}=T(t);for(let[i,l]of Object.entries(r))(l?.status==="fulfilled"||l?.status==="rejected")&&(s[i]=l)})}}),f=ae({name:`${e}/mutations`,initialState:Oe,reducers:{removeMutationResult:{reducer(Q,{payload:s}){let t=de(s);t in Q&&delete Q[t]},prepare:ge()}},extraReducers(Q){Q.addCase(d.pending,(s,{meta:t,meta:{requestId:r,arg:i,startedTimeStamp:l}})=>{i.track&&(s[de(t)]={requestId:r,status:"pending",endpointName:i.endpointName,startedTimeStamp:l})}).addCase(d.fulfilled,(s,{payload:t,meta:r})=>{r.arg.track&&ft(s,r,i=>{i.requestId===r.requestId&&(i.status="fulfilled",i.data=t,i.fulfilledTimeStamp=r.fulfilledTimeStamp)})}).addCase(d.rejected,(s,{payload:t,error:r,meta:i})=>{i.arg.track&&ft(s,i,l=>{l.requestId===i.requestId&&(l.status="rejected",l.error=t??r)})}).addMatcher(k,(s,t)=>{let{mutations:r}=T(t);for(let[i,l]of Object.entries(r))(l?.status==="fulfilled"||l?.status==="rejected")&&i!==l?.requestId&&(s[i]=l)})}}),B={tags:{},keys:{}},p=ae({name:`${e}/invalidation`,initialState:B,reducers:{updateProvidedBy:{reducer(Q,s){for(let{queryCacheKey:t,providedTags:r}of s.payload){o(Q,t);for(let{type:i,id:l}of r){let E=(Q.tags[i]??={})[l||"__internal_without_id"]??=[];E.includes(t)||E.push(t)}Q.keys[t]=r}},prepare:ge()}},extraReducers(Q){Q.addCase(a.actions.removeQueryResult,(s,{payload:{queryCacheKey:t}})=>{o(s,t)}).addMatcher(k,(s,t)=>{let{provided:r}=T(t);for(let[i,l]of Object.entries(r))for(let[E,v]of Object.entries(l)){let O=(s.tags[i]??={})[E||"__internal_without_id"]??=[];for(let C of v)O.includes(C)||O.push(C)}}).addMatcher(oe(W(n),me(n)),(s,t)=>{S(s,[t])}).addMatcher(a.actions.cacheEntriesUpserted.match,(s,t)=>{let r=t.payload.map(({queryDescription:i,value:l})=>({type:"UNKNOWN",payload:l,meta:{requestStatus:"fulfilled",requestId:"UNKNOWN",arg:i}}));S(s,r)})}});function o(Q,s){let t=Q.keys[s]??[];for(let r of t){let i=r.type,l=r.id??"__internal_without_id",E=Q.tags[i]?.[l];E&&(Q.tags[i][l]=E.filter(v=>v!==s))}delete Q.keys[s]}function S(Q,s){let t=s.map(r=>{let i=Fe(r,"providesTags",y,w),{queryCacheKey:l}=r.meta.arg;return{queryCacheKey:l,providedTags:i}});p.caseReducers.updateProvidedBy(Q,p.actions.updateProvidedBy(t))}let c=ae({name:`${e}/subscriptions`,initialState:Oe,reducers:{updateSubscriptionOptions(Q,s){},unsubscribeQueryResult(Q,s){},internal_getRTKQSubscriptions(){}}}),u=ae({name:`${e}/internalSubscriptions`,initialState:Oe,reducers:{subscriptionsUpdated:{reducer(Q,s){return lt(Q,s.payload)},prepare:ge()}}}),m=ae({name:`${e}/config`,initialState:{online:rt(),focused:nt(),middlewareRegistered:!1,...A},reducers:{middlewareRegistered(Q,{payload:s}){Q.middlewareRegistered=Q.middlewareRegistered==="conflict"||x!==s?"conflict":!0}},extraReducers:Q=>{Q.addCase(re,s=>{s.online=!0}).addCase(Te,s=>{s.online=!1}).addCase(ne,s=>{s.focused=!0}).addCase(Qe,s=>{s.focused=!1}).addMatcher(k,s=>({...s}))}}),D=Xe({queries:a.reducer,mutations:f.reducer,provided:p.reducer,subscriptions:u.reducer,config:m.reducer}),b=(Q,s)=>D(P.match(s)?void 0:Q,s),I={...m.actions,...a.actions,...c.actions,...u.actions,...f.actions,...p.actions,resetApiState:P};return{reducer:b,actions:I}}var Ne=Symbol.for("RTKQ/skipToken"),Tt={status:"uninitialized"},gt=Se(Tt,()=>{}),Qt=Se(Tt,()=>{});function ht({serializeQueryArgs:e,reducerPath:n,createSelector:d}){let g=c=>gt,y=c=>Qt;return{buildQuerySelector:R,buildInfiniteQuerySelector:a,buildMutationSelector:f,selectInvalidatedBy:B,selectCachedArgsForQuery:p,selectApiState:T,selectQueries:k,selectMutations:A,selectQueryEntry:w,selectConfig:P};function x(c){return{...c,...Le(c.status)}}function T(c){return c[n]}function k(c){return T(c)?.queries}function w(c,u){return k(c)?.[u]}function A(c){return T(c)?.mutations}function P(c){return T(c)?.config}function h(c,u,m){return D=>{if(D===Ne)return d(g,m);let b=e({queryArgs:D,endpointDefinition:u,endpointName:c});return d(Q=>w(Q,b)??gt,m)}}function R(c,u){return h(c,u,x)}function a(c,u){let{infiniteQueryOptions:m}=u;function D(b){let I={...b,...Le(b.status)},{isLoading:Q,isError:s,direction:t}=I,r=t==="forward",i=t==="backward";return{...I,hasNextPage:o(m,I.data,I.originalArgs),hasPreviousPage:S(m,I.data,I.originalArgs),isFetchingNextPage:Q&&r,isFetchingPreviousPage:Q&&i,isFetchNextPageError:s&&r,isFetchPreviousPageError:s&&i}}return h(c,u,D)}function f(){return c=>{let u;return typeof c=="object"?u=de(c)??Ne:u=c,d(u===Ne?y:b=>T(b)?.mutations?.[u]??Qt,x)}}function B(c,u){let m=c[n],D=new Set;for(let b of u.filter(se).map(we)){let I=m.provided.tags[b.type];if(!I)continue;let Q=(b.id!==void 0?I[b.id]:_e(Object.values(I)))??[];for(let s of Q)D.add(s)}return _e(Array.from(D.values()).map(b=>{let I=m.queries[b];return I?[{queryCacheKey:b,endpointName:I.endpointName,originalArgs:I.originalArgs}]:[]}))}function p(c,u){return Object.values(k(c)).filter(m=>m?.endpointName===u&&m.status!=="uninitialized").map(m=>m.originalArgs)}function o(c,u,m){return u?Ce(c,u,m)!=null:!1}function S(c,u,m){return!u||!c.getPreviousPageParam?!1:ze(c,u,m)!=null}}import{formatProdErrorMessage as Gt}from"@reduxjs/toolkit";var At=WeakMap?new WeakMap:void 0,qe=({endpointName:e,queryArgs:n})=>{let d="",g=At?.get(n);if(typeof g=="string")d=g;else{let y=JSON.stringify(n,(x,T)=>(T=typeof T=="bigint"?{$bigint:T.toString()}:T,T=te(T)?Object.keys(T).sort().reduce((k,w)=>(k[w]=T[w],k),{}):T,T));te(n)&&At?.set(n,y),d=y}return`${e}(${d})`};import{weakMapMemoize as Rt}from"reselect";function We(...e){return function(d){let g=Rt(A=>d.extractRehydrationInfo?.(A,{reducerPath:d.reducerPath??"api"})),y={reducerPath:"api",keepUnusedDataFor:60,refetchOnMountOrArgChange:!1,refetchOnFocus:!1,refetchOnReconnect:!1,invalidationBehavior:"delayed",...d,extractRehydrationInfo:g,serializeQueryArgs(A){let P=qe;if("serializeQueryArgs"in A.endpointDefinition){let h=A.endpointDefinition.serializeQueryArgs;P=R=>{let a=h(R);return typeof a=="string"?a:qe({...R,queryArgs:a})}}else d.serializeQueryArgs&&(P=d.serializeQueryArgs);return P(A)},tagTypes:[...d.tagTypes||[]]},x={endpointDefinitions:{},batch(A){A()},apiUid:Be(),extractRehydrationInfo:g,hasRehydrationInfo:Rt(A=>g(A)!=null)},T={injectEndpoints:w,enhanceEndpoints({addTagTypes:A,endpoints:P}){if(A)for(let h of A)y.tagTypes.includes(h)||y.tagTypes.push(h);if(P)for(let[h,R]of Object.entries(P))typeof R=="function"?R(x.endpointDefinitions[h]):Object.assign(x.endpointDefinitions[h]||{},R);return T}},k=e.map(A=>A.init(T,y,x));function w(A){let P=A.endpoints({query:h=>({...h,type:"query"}),mutation:h=>({...h,type:"mutation"}),infiniteQuery:h=>({...h,type:"infinitequery"})});for(let[h,R]of Object.entries(P)){if(A.overrideExisting!==!0&&h in x.endpointDefinitions){if(A.overrideExisting==="throw")throw new Error(Gt(39));continue}x.endpointDefinitions[h]=R;for(let a of k)a.injectEndpoint(h,R)}return T}return T.injectEndpoints({endpoints:d.endpoints})}}import{formatProdErrorMessage as Yt}from"@reduxjs/toolkit";var Xt=Symbol();function Zt(){return function(){throw new Error(Yt(33))}}import{enablePatches as rn}from"immer";function Y(e,...n){return Object.assign(e,...n)}import{produceWithPatches as en}from"immer";var St=({api:e,queryThunk:n,internalState:d})=>{let g=`${e.reducerPath}/subscriptions`,y=null,x=null,{updateSubscriptionOptions:T,unsubscribeQueryResult:k}=e.internalActions,w=(a,f)=>{if(T.match(f)){let{queryCacheKey:p,requestId:o,options:S}=f.payload;return a?.[p]?.[o]&&(a[p][o]=S),!0}if(k.match(f)){let{queryCacheKey:p,requestId:o}=f.payload;return a[p]&&delete a[p][o],!0}if(e.internalActions.removeQueryResult.match(f))return delete a[f.payload.queryCacheKey],!0;if(n.pending.match(f)){let{meta:{arg:p,requestId:o}}=f,S=a[p.queryCacheKey]??={};return S[`${o}_running`]={},p.subscribe&&(S[o]=p.subscriptionOptions??S[o]??{}),!0}let B=!1;if(n.fulfilled.match(f)||n.rejected.match(f)){let p=a[f.meta.arg.queryCacheKey]||{},o=`${f.meta.requestId}_running`;B||=!!p[o],delete p[o]}if(n.rejected.match(f)){let{meta:{condition:p,arg:o,requestId:S}}=f;if(p&&o.subscribe){let c=a[o.queryCacheKey]??={};c[S]=o.subscriptionOptions??c[S]??{},B=!0}}return B},A=()=>d.currentSubscriptions,R={getSubscriptions:A,getSubscriptionCount:a=>{let B=A()[a]??{};return J(B)},isRequestSubscribed:(a,f)=>!!A()?.[a]?.[f]};return(a,f)=>{if(y||(y=JSON.parse(JSON.stringify(d.currentSubscriptions))),e.util.resetApiState.match(a))return y=d.currentSubscriptions={},x=null,[!0,!1];if(e.internalActions.internal_getRTKQSubscriptions.match(a))return[!1,R];let B=w(d.currentSubscriptions,a),p=!0;if(B){x||(x=setTimeout(()=>{let c=JSON.parse(JSON.stringify(d.currentSubscriptions)),[,u]=en(y,()=>c);f.next(e.internalActions.subscriptionsUpdated(u)),y=c,x=null},500));let o=typeof a.type=="string"&&!!a.type.startsWith(g),S=n.rejected.match(a)&&a.meta.condition&&!!a.meta.arg.subscribe;p=!o&&!S}return[p,!1]}};function tn(e){for(let n in e)return!1;return!0}var nn=2147483647/1e3-1,xt=({reducerPath:e,api:n,queryThunk:d,context:g,internalState:y,selectors:{selectQueryEntry:x,selectConfig:T}})=>{let{removeQueryResult:k,unsubscribeQueryResult:w,cacheEntriesUpserted:A}=n.internalActions,P=oe(w.match,d.fulfilled,d.rejected,A.match);function h(p){let o=y.currentSubscriptions[p];return!!o&&!tn(o)}let R={},a=(p,o,S)=>{let c=o.getState(),u=T(c);if(P(p)){let m;if(A.match(p))m=p.payload.map(D=>D.queryDescription.queryCacheKey);else{let{queryCacheKey:D}=w.match(p)?p.payload:p.meta.arg;m=[D]}f(m,o,u)}if(n.util.resetApiState.match(p))for(let[m,D]of Object.entries(R))D&&clearTimeout(D),delete R[m];if(g.hasRehydrationInfo(p)){let{queries:m}=g.extractRehydrationInfo(p);f(Object.keys(m),o,u)}};function f(p,o,S){let c=o.getState();for(let u of p){let m=x(c,u);B(u,m?.endpointName,o,S)}}function B(p,o,S,c){let m=g.endpointDefinitions[o]?.keepUnusedDataFor??c.keepUnusedDataFor;if(m===1/0)return;let D=Math.max(0,Math.min(m,nn));if(!h(p)){let b=R[p];b&&clearTimeout(b),R[p]=setTimeout(()=>{h(p)||S.dispatch(k({queryCacheKey:p})),delete R[p]},D*1e3)}}return a};var Dt=new Error("Promise never resolved before cacheEntryRemoved."),bt=({api:e,reducerPath:n,context:d,queryThunk:g,mutationThunk:y,internalState:x,selectors:{selectQueryEntry:T,selectApiState:k}})=>{let w=He(g),A=He(y),P=W(g,y),h={};function R(o,S,c){let u=h[o];u?.valueResolved&&(u.valueResolved({data:S,meta:c}),delete u.valueResolved)}function a(o){let S=h[o];S&&(delete h[o],S.cacheEntryRemoved())}let f=(o,S,c)=>{let u=B(o);function m(D,b,I,Q){let s=T(c,b),t=T(S.getState(),b);!s&&t&&p(D,Q,b,S,I)}if(g.pending.match(o))m(o.meta.arg.endpointName,u,o.meta.requestId,o.meta.arg.originalArgs);else if(e.internalActions.cacheEntriesUpserted.match(o))for(let{queryDescription:D,value:b}of o.payload){let{endpointName:I,originalArgs:Q,queryCacheKey:s}=D;m(I,s,o.meta.requestId,Q),R(s,b,{})}else if(y.pending.match(o))S.getState()[n].mutations[u]&&p(o.meta.arg.endpointName,o.meta.arg.originalArgs,u,S,o.meta.requestId);else if(P(o))R(u,o.payload,o.meta.baseQueryMeta);else if(e.internalActions.removeQueryResult.match(o)||e.internalActions.removeMutationResult.match(o))a(u);else if(e.util.resetApiState.match(o))for(let D of Object.keys(h))a(D)};function B(o){return w(o)?o.meta.arg.queryCacheKey:A(o)?o.meta.arg.fixedCacheKey??o.meta.requestId:e.internalActions.removeQueryResult.match(o)?o.payload.queryCacheKey:e.internalActions.removeMutationResult.match(o)?de(o.payload):""}function p(o,S,c,u,m){let D=d.endpointDefinitions[o],b=D?.onCacheEntryAdded;if(!b)return;let I={},Q=new Promise(E=>{I.cacheEntryRemoved=E}),s=Promise.race([new Promise(E=>{I.valueResolved=E}),Q.then(()=>{throw Dt})]);s.catch(()=>{}),h[c]=I;let t=e.endpoints[o].select(he(D)?S:c),r=u.dispatch((E,v,O)=>O),i={...u,getCacheEntry:()=>t(u.getState()),requestId:m,extra:r,updateCachedData:he(D)?E=>u.dispatch(e.util.updateQueryData(o,S,E)):void 0,cacheDataLoaded:s,cacheEntryRemoved:Q},l=b(S,i);Promise.resolve(l).catch(E=>{if(E!==Dt)throw E})}return f};var Et=({api:e,context:{apiUid:n},reducerPath:d})=>(g,y)=>{e.util.resetApiState.match(g)&&y.dispatch(e.internalActions.middlewareRegistered(n))};var Pt=({reducerPath:e,context:n,context:{endpointDefinitions:d},mutationThunk:g,queryThunk:y,api:x,assertTagType:T,refetchQuery:k,internalState:w})=>{let{removeQueryResult:A}=x.internalActions,P=oe(W(g),me(g)),h=oe(W(g,y),fe(g,y)),R=[],a=(p,o)=>{P(p)?B(Fe(p,"invalidatesTags",d,T),o):h(p)?B([],o):x.util.invalidateTags.match(p)&&B(xe(p.payload,void 0,void 0,void 0,void 0,T),o)};function f(p){let{queries:o,mutations:S}=p;for(let c of[o,S])for(let u in c)if(c[u]?.status==="pending")return!0;return!1}function B(p,o){let S=o.getState(),c=S[e];if(R.push(...p),c.config.invalidationBehavior==="delayed"&&f(c))return;let u=R;if(R=[],u.length===0)return;let m=x.util.selectInvalidatedBy(S,u);n.batch(()=>{let D=Array.from(m.values());for(let{queryCacheKey:b}of D){let I=c.queries[b],Q=w.currentSubscriptions[b]??{};I&&(J(Q)===0?o.dispatch(A({queryCacheKey:b})):I.status!=="uninitialized"&&o.dispatch(k(I)))}})}return a};var It=({reducerPath:e,queryThunk:n,api:d,refetchQuery:g,internalState:y})=>{let x={},T=(a,f)=>{(d.internalActions.updateSubscriptionOptions.match(a)||d.internalActions.unsubscribeQueryResult.match(a))&&A(a.payload,f),(n.pending.match(a)||n.rejected.match(a)&&a.meta.condition)&&A(a.meta.arg,f),(n.fulfilled.match(a)||n.rejected.match(a)&&!a.meta.condition)&&w(a.meta.arg,f),d.util.resetApiState.match(a)&&h()};function k(a,f){let p=f.getState()[e].queries[a],o=y.currentSubscriptions[a];if(!(!p||p.status==="uninitialized"))return o}function w({queryCacheKey:a},f){let B=f.getState()[e],p=B.queries[a],o=y.currentSubscriptions[a];if(!p||p.status==="uninitialized")return;let{lowestPollingInterval:S,skipPollingIfUnfocused:c}=R(o);if(!Number.isFinite(S))return;let u=x[a];u?.timeout&&(clearTimeout(u.timeout),u.timeout=void 0);let m=Date.now()+S;x[a]={nextPollTimestamp:m,pollingInterval:S,timeout:setTimeout(()=>{(B.config.focused||!c)&&f.dispatch(g(p)),w({queryCacheKey:a},f)},S)}}function A({queryCacheKey:a},f){let p=f.getState()[e].queries[a],o=y.currentSubscriptions[a];if(!p||p.status==="uninitialized")return;let{lowestPollingInterval:S}=R(o);if(!Number.isFinite(S)){P(a);return}let c=x[a],u=Date.now()+S;(!c||u<c.nextPollTimestamp)&&w({queryCacheKey:a},f)}function P(a){let f=x[a];f?.timeout&&clearTimeout(f.timeout),delete x[a]}function h(){for(let a of Object.keys(x))P(a)}function R(a={}){let f=!1,B=Number.POSITIVE_INFINITY;for(let p in a)a[p].pollingInterval&&(B=Math.min(a[p].pollingInterval,B),f=a[p].skipPollingIfUnfocused||f);return{lowestPollingInterval:B,skipPollingIfUnfocused:f}}return T};var kt=({api:e,context:n,queryThunk:d,mutationThunk:g})=>{let y=Ie(d,g),x=fe(d,g),T=W(d,g),k={};return(A,P)=>{if(y(A)){let{requestId:h,arg:{endpointName:R,originalArgs:a}}=A.meta,f=n.endpointDefinitions[R],B=f?.onQueryStarted;if(B){let p={},o=new Promise((m,D)=>{p.resolve=m,p.reject=D});o.catch(()=>{}),k[h]=p;let S=e.endpoints[R].select(he(f)?a:h),c=P.dispatch((m,D,b)=>b),u={...P,getCacheEntry:()=>S(P.getState()),requestId:h,extra:c,updateCachedData:he(f)?m=>P.dispatch(e.util.updateQueryData(R,a,m)):void 0,queryFulfilled:o};B(a,u)}}else if(T(A)){let{requestId:h,baseQueryMeta:R}=A.meta;k[h]?.resolve({data:A.payload,meta:R}),delete k[h]}else if(x(A)){let{requestId:h,rejectedWithValue:R,baseQueryMeta:a}=A.meta;k[h]?.reject({error:A.payload??A.error,isUnhandledError:!R,meta:a}),delete k[h]}}};var Bt=({reducerPath:e,context:n,api:d,refetchQuery:g,internalState:y})=>{let{removeQueryResult:x}=d.internalActions,T=(w,A)=>{ne.match(w)&&k(A,"refetchOnFocus"),re.match(w)&&k(A,"refetchOnReconnect")};function k(w,A){let P=w.getState()[e],h=P.queries,R=y.currentSubscriptions;n.batch(()=>{for(let a of Object.keys(R)){let f=h[a],B=R[a];if(!B||!f)continue;(Object.values(B).some(o=>o[A]===!0)||Object.values(B).every(o=>o[A]===void 0)&&P.config[A])&&(J(B)===0?w.dispatch(x({queryCacheKey:a})):f.status!=="uninitialized"&&w.dispatch(g(f)))}})}return T};function Mt(e){let{reducerPath:n,queryThunk:d,api:g,context:y}=e,{apiUid:x}=y,T={invalidateTags:X(`${n}/invalidateTags`)},k=h=>h.type.startsWith(`${n}/`),w=[Et,xt,Pt,It,bt,kt];return{middleware:h=>{let R=!1,f={...e,internalState:{currentSubscriptions:{}},refetchQuery:P,isThisApiSliceAction:k},B=w.map(S=>S(f)),p=St(f),o=Bt(f);return S=>c=>{if(!Ze(c))return S(c);R||(R=!0,h.dispatch(g.internalActions.middlewareRegistered(x)));let u={...h,next:S},m=h.getState(),[D,b]=p(c,u,m),I;if(D?I=S(c):I=b,h.getState()[n]&&(o(c,u,m),k(c)||y.hasRehydrationInfo(c)))for(let Q of B)Q(c,u,m);return I}},actions:T};function P(h){return e.api.endpoints[h.endpointName].initiate(h.originalArgs,{subscribe:!1,forceRefetch:!0})}}var Ke=Symbol(),$e=({createSelector:e=Ye}={})=>({name:Ke,init(n,{baseQuery:d,tagTypes:g,reducerPath:y,serializeQueryArgs:x,keepUnusedDataFor:T,refetchOnMountOrArgChange:k,refetchOnFocus:w,refetchOnReconnect:A,invalidationBehavior:P,onSchemaFailure:h,catchSchemaFailure:R,skipSchemaValidation:a},f){rn();let B=F=>F;Object.assign(n,{reducerPath:y,endpoints:{},internalActions:{onOnline:re,onOffline:Te,onFocus:ne,onFocusLost:Qe},util:{}});let p=ht({serializeQueryArgs:x,reducerPath:y,createSelector:e}),{selectInvalidatedBy:o,selectCachedArgsForQuery:S,buildQuerySelector:c,buildInfiniteQuerySelector:u,buildMutationSelector:m}=p;Y(n.util,{selectInvalidatedBy:o,selectCachedArgsForQuery:S});let{queryThunk:D,infiniteQueryThunk:b,mutationThunk:I,patchQueryData:Q,updateQueryData:s,upsertQueryData:t,prefetch:r,buildMatchThunkActions:i}=ct({baseQuery:d,reducerPath:y,context:f,api:n,serializeQueryArgs:x,assertTagType:B,selectors:p,onSchemaFailure:h,catchSchemaFailure:R,skipSchemaValidation:a}),{reducer:l,actions:E}=mt({context:f,queryThunk:D,infiniteQueryThunk:b,mutationThunk:I,serializeQueryArgs:x,reducerPath:y,assertTagType:B,config:{refetchOnFocus:w,refetchOnReconnect:A,refetchOnMountOrArgChange:k,keepUnusedDataFor:T,reducerPath:y,invalidationBehavior:P}});Y(n.util,{patchQueryData:Q,updateQueryData:s,upsertQueryData:t,prefetch:r,resetApiState:E.resetApiState,upsertQueryEntries:E.cacheEntriesUpserted}),Y(n.internalActions,E);let{middleware:v,actions:O}=Mt({reducerPath:y,context:f,queryThunk:D,mutationThunk:I,infiniteQueryThunk:b,api:n,assertTagType:B,selectors:p});Y(n.util,O),Y(n,{reducer:l,middleware:v});let{buildInitiateQuery:C,buildInitiateInfiniteQuery:M,buildInitiateMutation:K,getRunningMutationThunk:j,getRunningMutationsThunk:z,getRunningQueriesThunk:L,getRunningQueryThunk:N}=pt({queryThunk:D,mutationThunk:I,infiniteQueryThunk:b,api:n,serializeQueryArgs:x,context:f});return Y(n.util,{getRunningMutationThunk:j,getRunningMutationsThunk:z,getRunningQueryThunk:N,getRunningQueriesThunk:L}),{name:Ke,injectEndpoint(F,_){let H=n,q=H.endpoints[F]??={};ue(_)&&Y(q,{name:F,select:c(F,_),initiate:C(F,_)},i(D,F)),yt(_)&&Y(q,{name:F,select:m(),initiate:K(F)},i(I,F)),ye(_)&&Y(q,{name:F,select:u(F,_),initiate:M(F,_)},i(D,F))}}}});var an=We($e());export{Re as NamedSchemaError,Ue as QueryStatus,Xt as _NEVER,We as buildCreateApi,Me as copyWithStructuralSharing,$e as coreModule,Ke as coreModuleName,an as createApi,qe as defaultSerializeQueryArgs,Zt as fakeBaseQuery,Nt as fetchBaseQuery,Lt as retry,jt as setupListeners,Ne as skipToken};
|
| 2 |
+
//# sourceMappingURL=rtk-query.browser.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.browser.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.legacy-esm.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs
ADDED
|
@@ -0,0 +1,2885 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/query/core/apiState.ts
|
| 2 |
+
var QueryStatus = /* @__PURE__ */ ((QueryStatus2) => {
|
| 3 |
+
QueryStatus2["uninitialized"] = "uninitialized";
|
| 4 |
+
QueryStatus2["pending"] = "pending";
|
| 5 |
+
QueryStatus2["fulfilled"] = "fulfilled";
|
| 6 |
+
QueryStatus2["rejected"] = "rejected";
|
| 7 |
+
return QueryStatus2;
|
| 8 |
+
})(QueryStatus || {});
|
| 9 |
+
function getRequestStatusFlags(status) {
|
| 10 |
+
return {
|
| 11 |
+
status,
|
| 12 |
+
isUninitialized: status === "uninitialized" /* uninitialized */,
|
| 13 |
+
isLoading: status === "pending" /* pending */,
|
| 14 |
+
isSuccess: status === "fulfilled" /* fulfilled */,
|
| 15 |
+
isError: status === "rejected" /* rejected */
|
| 16 |
+
};
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// src/query/core/rtkImports.ts
|
| 20 |
+
import { createAction, createSlice, createSelector, createAsyncThunk, combineReducers, createNextState, isAnyOf, isAllOf, isAction, isPending, isRejected, isFulfilled, isRejectedWithValue, isAsyncThunkAction, prepareAutoBatched, SHOULD_AUTOBATCH, isPlainObject, nanoid } from "@reduxjs/toolkit";
|
| 21 |
+
|
| 22 |
+
// src/query/utils/copyWithStructuralSharing.ts
|
| 23 |
+
var isPlainObject2 = isPlainObject;
|
| 24 |
+
function copyWithStructuralSharing(oldObj, newObj) {
|
| 25 |
+
if (oldObj === newObj || !(isPlainObject2(oldObj) && isPlainObject2(newObj) || Array.isArray(oldObj) && Array.isArray(newObj))) {
|
| 26 |
+
return newObj;
|
| 27 |
+
}
|
| 28 |
+
const newKeys = Object.keys(newObj);
|
| 29 |
+
const oldKeys = Object.keys(oldObj);
|
| 30 |
+
let isSameObject = newKeys.length === oldKeys.length;
|
| 31 |
+
const mergeObj = Array.isArray(newObj) ? [] : {};
|
| 32 |
+
for (const key of newKeys) {
|
| 33 |
+
mergeObj[key] = copyWithStructuralSharing(oldObj[key], newObj[key]);
|
| 34 |
+
if (isSameObject) isSameObject = oldObj[key] === mergeObj[key];
|
| 35 |
+
}
|
| 36 |
+
return isSameObject ? oldObj : mergeObj;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// src/query/utils/countObjectKeys.ts
|
| 40 |
+
function countObjectKeys(obj) {
|
| 41 |
+
let count = 0;
|
| 42 |
+
for (const _key in obj) {
|
| 43 |
+
count++;
|
| 44 |
+
}
|
| 45 |
+
return count;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// src/query/utils/flatten.ts
|
| 49 |
+
var flatten = (arr) => [].concat(...arr);
|
| 50 |
+
|
| 51 |
+
// src/query/utils/isAbsoluteUrl.ts
|
| 52 |
+
function isAbsoluteUrl(url) {
|
| 53 |
+
return new RegExp(`(^|:)//`).test(url);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
// src/query/utils/isDocumentVisible.ts
|
| 57 |
+
function isDocumentVisible() {
|
| 58 |
+
if (typeof document === "undefined") {
|
| 59 |
+
return true;
|
| 60 |
+
}
|
| 61 |
+
return document.visibilityState !== "hidden";
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// src/query/utils/isNotNullish.ts
|
| 65 |
+
function isNotNullish(v) {
|
| 66 |
+
return v != null;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// src/query/utils/isOnline.ts
|
| 70 |
+
function isOnline() {
|
| 71 |
+
return typeof navigator === "undefined" ? true : navigator.onLine === void 0 ? true : navigator.onLine;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// src/query/utils/joinUrls.ts
|
| 75 |
+
var withoutTrailingSlash = (url) => url.replace(/\/$/, "");
|
| 76 |
+
var withoutLeadingSlash = (url) => url.replace(/^\//, "");
|
| 77 |
+
function joinUrls(base, url) {
|
| 78 |
+
if (!base) {
|
| 79 |
+
return url;
|
| 80 |
+
}
|
| 81 |
+
if (!url) {
|
| 82 |
+
return base;
|
| 83 |
+
}
|
| 84 |
+
if (isAbsoluteUrl(url)) {
|
| 85 |
+
return url;
|
| 86 |
+
}
|
| 87 |
+
const delimiter = base.endsWith("/") || !url.startsWith("?") ? "/" : "";
|
| 88 |
+
base = withoutTrailingSlash(base);
|
| 89 |
+
url = withoutLeadingSlash(url);
|
| 90 |
+
return `${base}${delimiter}${url}`;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// src/query/utils/getOrInsert.ts
|
| 94 |
+
function getOrInsert(map, key, value) {
|
| 95 |
+
if (map.has(key)) return map.get(key);
|
| 96 |
+
return map.set(key, value).get(key);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
// src/query/fetchBaseQuery.ts
|
| 100 |
+
var defaultFetchFn = (...args) => fetch(...args);
|
| 101 |
+
var defaultValidateStatus = (response) => response.status >= 200 && response.status <= 299;
|
| 102 |
+
var defaultIsJsonContentType = (headers) => (
|
| 103 |
+
/*applicat*/
|
| 104 |
+
/ion\/(vnd\.api\+)?json/.test(headers.get("content-type") || "")
|
| 105 |
+
);
|
| 106 |
+
function stripUndefined(obj) {
|
| 107 |
+
if (!isPlainObject(obj)) {
|
| 108 |
+
return obj;
|
| 109 |
+
}
|
| 110 |
+
const copy = {
|
| 111 |
+
...obj
|
| 112 |
+
};
|
| 113 |
+
for (const [k, v] of Object.entries(copy)) {
|
| 114 |
+
if (v === void 0) delete copy[k];
|
| 115 |
+
}
|
| 116 |
+
return copy;
|
| 117 |
+
}
|
| 118 |
+
function fetchBaseQuery({
|
| 119 |
+
baseUrl,
|
| 120 |
+
prepareHeaders = (x) => x,
|
| 121 |
+
fetchFn = defaultFetchFn,
|
| 122 |
+
paramsSerializer,
|
| 123 |
+
isJsonContentType = defaultIsJsonContentType,
|
| 124 |
+
jsonContentType = "application/json",
|
| 125 |
+
jsonReplacer,
|
| 126 |
+
timeout: defaultTimeout,
|
| 127 |
+
responseHandler: globalResponseHandler,
|
| 128 |
+
validateStatus: globalValidateStatus,
|
| 129 |
+
...baseFetchOptions
|
| 130 |
+
} = {}) {
|
| 131 |
+
if (typeof fetch === "undefined" && fetchFn === defaultFetchFn) {
|
| 132 |
+
console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments.");
|
| 133 |
+
}
|
| 134 |
+
return async (arg, api, extraOptions) => {
|
| 135 |
+
const {
|
| 136 |
+
getState,
|
| 137 |
+
extra,
|
| 138 |
+
endpoint,
|
| 139 |
+
forced,
|
| 140 |
+
type
|
| 141 |
+
} = api;
|
| 142 |
+
let meta;
|
| 143 |
+
let {
|
| 144 |
+
url,
|
| 145 |
+
headers = new Headers(baseFetchOptions.headers),
|
| 146 |
+
params = void 0,
|
| 147 |
+
responseHandler = globalResponseHandler ?? "json",
|
| 148 |
+
validateStatus = globalValidateStatus ?? defaultValidateStatus,
|
| 149 |
+
timeout = defaultTimeout,
|
| 150 |
+
...rest
|
| 151 |
+
} = typeof arg == "string" ? {
|
| 152 |
+
url: arg
|
| 153 |
+
} : arg;
|
| 154 |
+
let abortController, signal = api.signal;
|
| 155 |
+
if (timeout) {
|
| 156 |
+
abortController = new AbortController();
|
| 157 |
+
api.signal.addEventListener("abort", abortController.abort);
|
| 158 |
+
signal = abortController.signal;
|
| 159 |
+
}
|
| 160 |
+
let config = {
|
| 161 |
+
...baseFetchOptions,
|
| 162 |
+
signal,
|
| 163 |
+
...rest
|
| 164 |
+
};
|
| 165 |
+
headers = new Headers(stripUndefined(headers));
|
| 166 |
+
config.headers = await prepareHeaders(headers, {
|
| 167 |
+
getState,
|
| 168 |
+
arg,
|
| 169 |
+
extra,
|
| 170 |
+
endpoint,
|
| 171 |
+
forced,
|
| 172 |
+
type,
|
| 173 |
+
extraOptions
|
| 174 |
+
}) || headers;
|
| 175 |
+
const isJsonifiable = (body) => typeof body === "object" && (isPlainObject(body) || Array.isArray(body) || typeof body.toJSON === "function");
|
| 176 |
+
if (!config.headers.has("content-type") && isJsonifiable(config.body)) {
|
| 177 |
+
config.headers.set("content-type", jsonContentType);
|
| 178 |
+
}
|
| 179 |
+
if (isJsonifiable(config.body) && isJsonContentType(config.headers)) {
|
| 180 |
+
config.body = JSON.stringify(config.body, jsonReplacer);
|
| 181 |
+
}
|
| 182 |
+
if (params) {
|
| 183 |
+
const divider = ~url.indexOf("?") ? "&" : "?";
|
| 184 |
+
const query = paramsSerializer ? paramsSerializer(params) : new URLSearchParams(stripUndefined(params));
|
| 185 |
+
url += divider + query;
|
| 186 |
+
}
|
| 187 |
+
url = joinUrls(baseUrl, url);
|
| 188 |
+
const request = new Request(url, config);
|
| 189 |
+
const requestClone = new Request(url, config);
|
| 190 |
+
meta = {
|
| 191 |
+
request: requestClone
|
| 192 |
+
};
|
| 193 |
+
let response, timedOut = false, timeoutId = abortController && setTimeout(() => {
|
| 194 |
+
timedOut = true;
|
| 195 |
+
abortController.abort();
|
| 196 |
+
}, timeout);
|
| 197 |
+
try {
|
| 198 |
+
response = await fetchFn(request);
|
| 199 |
+
} catch (e) {
|
| 200 |
+
return {
|
| 201 |
+
error: {
|
| 202 |
+
status: timedOut ? "TIMEOUT_ERROR" : "FETCH_ERROR",
|
| 203 |
+
error: String(e)
|
| 204 |
+
},
|
| 205 |
+
meta
|
| 206 |
+
};
|
| 207 |
+
} finally {
|
| 208 |
+
if (timeoutId) clearTimeout(timeoutId);
|
| 209 |
+
abortController?.signal.removeEventListener("abort", abortController.abort);
|
| 210 |
+
}
|
| 211 |
+
const responseClone = response.clone();
|
| 212 |
+
meta.response = responseClone;
|
| 213 |
+
let resultData;
|
| 214 |
+
let responseText = "";
|
| 215 |
+
try {
|
| 216 |
+
let handleResponseError;
|
| 217 |
+
await Promise.all([
|
| 218 |
+
handleResponse(response, responseHandler).then((r) => resultData = r, (e) => handleResponseError = e),
|
| 219 |
+
// see https://github.com/node-fetch/node-fetch/issues/665#issuecomment-538995182
|
| 220 |
+
// we *have* to "use up" both streams at the same time or they will stop running in node-fetch scenarios
|
| 221 |
+
responseClone.text().then((r) => responseText = r, () => {
|
| 222 |
+
})
|
| 223 |
+
]);
|
| 224 |
+
if (handleResponseError) throw handleResponseError;
|
| 225 |
+
} catch (e) {
|
| 226 |
+
return {
|
| 227 |
+
error: {
|
| 228 |
+
status: "PARSING_ERROR",
|
| 229 |
+
originalStatus: response.status,
|
| 230 |
+
data: responseText,
|
| 231 |
+
error: String(e)
|
| 232 |
+
},
|
| 233 |
+
meta
|
| 234 |
+
};
|
| 235 |
+
}
|
| 236 |
+
return validateStatus(response, resultData) ? {
|
| 237 |
+
data: resultData,
|
| 238 |
+
meta
|
| 239 |
+
} : {
|
| 240 |
+
error: {
|
| 241 |
+
status: response.status,
|
| 242 |
+
data: resultData
|
| 243 |
+
},
|
| 244 |
+
meta
|
| 245 |
+
};
|
| 246 |
+
};
|
| 247 |
+
async function handleResponse(response, responseHandler) {
|
| 248 |
+
if (typeof responseHandler === "function") {
|
| 249 |
+
return responseHandler(response);
|
| 250 |
+
}
|
| 251 |
+
if (responseHandler === "content-type") {
|
| 252 |
+
responseHandler = isJsonContentType(response.headers) ? "json" : "text";
|
| 253 |
+
}
|
| 254 |
+
if (responseHandler === "json") {
|
| 255 |
+
const text = await response.text();
|
| 256 |
+
return text.length ? JSON.parse(text) : null;
|
| 257 |
+
}
|
| 258 |
+
return response.text();
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// src/query/HandledError.ts
|
| 263 |
+
var HandledError = class {
|
| 264 |
+
constructor(value, meta = void 0) {
|
| 265 |
+
this.value = value;
|
| 266 |
+
this.meta = meta;
|
| 267 |
+
}
|
| 268 |
+
};
|
| 269 |
+
|
| 270 |
+
// src/query/retry.ts
|
| 271 |
+
async function defaultBackoff(attempt = 0, maxRetries = 5) {
|
| 272 |
+
const attempts = Math.min(attempt, maxRetries);
|
| 273 |
+
const timeout = ~~((Math.random() + 0.4) * (300 << attempts));
|
| 274 |
+
await new Promise((resolve) => setTimeout((res) => resolve(res), timeout));
|
| 275 |
+
}
|
| 276 |
+
function fail(error, meta) {
|
| 277 |
+
throw Object.assign(new HandledError({
|
| 278 |
+
error,
|
| 279 |
+
meta
|
| 280 |
+
}), {
|
| 281 |
+
throwImmediately: true
|
| 282 |
+
});
|
| 283 |
+
}
|
| 284 |
+
var EMPTY_OPTIONS = {};
|
| 285 |
+
var retryWithBackoff = (baseQuery, defaultOptions) => async (args, api, extraOptions) => {
|
| 286 |
+
const possibleMaxRetries = [5, (defaultOptions || EMPTY_OPTIONS).maxRetries, (extraOptions || EMPTY_OPTIONS).maxRetries].filter((x) => x !== void 0);
|
| 287 |
+
const [maxRetries] = possibleMaxRetries.slice(-1);
|
| 288 |
+
const defaultRetryCondition = (_, __, {
|
| 289 |
+
attempt
|
| 290 |
+
}) => attempt <= maxRetries;
|
| 291 |
+
const options = {
|
| 292 |
+
maxRetries,
|
| 293 |
+
backoff: defaultBackoff,
|
| 294 |
+
retryCondition: defaultRetryCondition,
|
| 295 |
+
...defaultOptions,
|
| 296 |
+
...extraOptions
|
| 297 |
+
};
|
| 298 |
+
let retry2 = 0;
|
| 299 |
+
while (true) {
|
| 300 |
+
try {
|
| 301 |
+
const result = await baseQuery(args, api, extraOptions);
|
| 302 |
+
if (result.error) {
|
| 303 |
+
throw new HandledError(result);
|
| 304 |
+
}
|
| 305 |
+
return result;
|
| 306 |
+
} catch (e) {
|
| 307 |
+
retry2++;
|
| 308 |
+
if (e.throwImmediately) {
|
| 309 |
+
if (e instanceof HandledError) {
|
| 310 |
+
return e.value;
|
| 311 |
+
}
|
| 312 |
+
throw e;
|
| 313 |
+
}
|
| 314 |
+
if (e instanceof HandledError && !options.retryCondition(e.value.error, args, {
|
| 315 |
+
attempt: retry2,
|
| 316 |
+
baseQueryApi: api,
|
| 317 |
+
extraOptions
|
| 318 |
+
})) {
|
| 319 |
+
return e.value;
|
| 320 |
+
}
|
| 321 |
+
await options.backoff(retry2, options.maxRetries);
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
};
|
| 325 |
+
var retry = /* @__PURE__ */ Object.assign(retryWithBackoff, {
|
| 326 |
+
fail
|
| 327 |
+
});
|
| 328 |
+
|
| 329 |
+
// src/query/core/setupListeners.ts
|
| 330 |
+
var onFocus = /* @__PURE__ */ createAction("__rtkq/focused");
|
| 331 |
+
var onFocusLost = /* @__PURE__ */ createAction("__rtkq/unfocused");
|
| 332 |
+
var onOnline = /* @__PURE__ */ createAction("__rtkq/online");
|
| 333 |
+
var onOffline = /* @__PURE__ */ createAction("__rtkq/offline");
|
| 334 |
+
var initialized = false;
|
| 335 |
+
function setupListeners(dispatch, customHandler) {
|
| 336 |
+
function defaultHandler() {
|
| 337 |
+
const handleFocus = () => dispatch(onFocus());
|
| 338 |
+
const handleFocusLost = () => dispatch(onFocusLost());
|
| 339 |
+
const handleOnline = () => dispatch(onOnline());
|
| 340 |
+
const handleOffline = () => dispatch(onOffline());
|
| 341 |
+
const handleVisibilityChange = () => {
|
| 342 |
+
if (window.document.visibilityState === "visible") {
|
| 343 |
+
handleFocus();
|
| 344 |
+
} else {
|
| 345 |
+
handleFocusLost();
|
| 346 |
+
}
|
| 347 |
+
};
|
| 348 |
+
if (!initialized) {
|
| 349 |
+
if (typeof window !== "undefined" && window.addEventListener) {
|
| 350 |
+
window.addEventListener("visibilitychange", handleVisibilityChange, false);
|
| 351 |
+
window.addEventListener("focus", handleFocus, false);
|
| 352 |
+
window.addEventListener("online", handleOnline, false);
|
| 353 |
+
window.addEventListener("offline", handleOffline, false);
|
| 354 |
+
initialized = true;
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
const unsubscribe = () => {
|
| 358 |
+
window.removeEventListener("focus", handleFocus);
|
| 359 |
+
window.removeEventListener("visibilitychange", handleVisibilityChange);
|
| 360 |
+
window.removeEventListener("online", handleOnline);
|
| 361 |
+
window.removeEventListener("offline", handleOffline);
|
| 362 |
+
initialized = false;
|
| 363 |
+
};
|
| 364 |
+
return unsubscribe;
|
| 365 |
+
}
|
| 366 |
+
return customHandler ? customHandler(dispatch, {
|
| 367 |
+
onFocus,
|
| 368 |
+
onFocusLost,
|
| 369 |
+
onOffline,
|
| 370 |
+
onOnline
|
| 371 |
+
}) : defaultHandler();
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
// src/query/endpointDefinitions.ts
|
| 375 |
+
function isQueryDefinition(e) {
|
| 376 |
+
return e.type === "query" /* query */;
|
| 377 |
+
}
|
| 378 |
+
function isMutationDefinition(e) {
|
| 379 |
+
return e.type === "mutation" /* mutation */;
|
| 380 |
+
}
|
| 381 |
+
function isInfiniteQueryDefinition(e) {
|
| 382 |
+
return e.type === "infinitequery" /* infinitequery */;
|
| 383 |
+
}
|
| 384 |
+
function isAnyQueryDefinition(e) {
|
| 385 |
+
return isQueryDefinition(e) || isInfiniteQueryDefinition(e);
|
| 386 |
+
}
|
| 387 |
+
function calculateProvidedBy(description, result, error, queryArg, meta, assertTagTypes) {
|
| 388 |
+
if (isFunction(description)) {
|
| 389 |
+
return description(result, error, queryArg, meta).filter(isNotNullish).map(expandTagDescription).map(assertTagTypes);
|
| 390 |
+
}
|
| 391 |
+
if (Array.isArray(description)) {
|
| 392 |
+
return description.map(expandTagDescription).map(assertTagTypes);
|
| 393 |
+
}
|
| 394 |
+
return [];
|
| 395 |
+
}
|
| 396 |
+
function isFunction(t) {
|
| 397 |
+
return typeof t === "function";
|
| 398 |
+
}
|
| 399 |
+
function expandTagDescription(description) {
|
| 400 |
+
return typeof description === "string" ? {
|
| 401 |
+
type: description
|
| 402 |
+
} : description;
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
// src/query/core/buildThunks.ts
|
| 406 |
+
import { isDraftable, produceWithPatches } from "immer";
|
| 407 |
+
|
| 408 |
+
// src/query/core/buildInitiate.ts
|
| 409 |
+
import { formatProdErrorMessage as _formatProdErrorMessage } from "@reduxjs/toolkit";
|
| 410 |
+
|
| 411 |
+
// src/tsHelpers.ts
|
| 412 |
+
function asSafePromise(promise, fallback) {
|
| 413 |
+
return promise.catch(fallback);
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
// src/query/core/buildInitiate.ts
|
| 417 |
+
var forceQueryFnSymbol = Symbol("forceQueryFn");
|
| 418 |
+
var isUpsertQuery = (arg) => typeof arg[forceQueryFnSymbol] === "function";
|
| 419 |
+
function buildInitiate({
|
| 420 |
+
serializeQueryArgs,
|
| 421 |
+
queryThunk,
|
| 422 |
+
infiniteQueryThunk,
|
| 423 |
+
mutationThunk,
|
| 424 |
+
api,
|
| 425 |
+
context
|
| 426 |
+
}) {
|
| 427 |
+
const runningQueries = /* @__PURE__ */ new Map();
|
| 428 |
+
const runningMutations = /* @__PURE__ */ new Map();
|
| 429 |
+
const {
|
| 430 |
+
unsubscribeQueryResult,
|
| 431 |
+
removeMutationResult,
|
| 432 |
+
updateSubscriptionOptions
|
| 433 |
+
} = api.internalActions;
|
| 434 |
+
return {
|
| 435 |
+
buildInitiateQuery,
|
| 436 |
+
buildInitiateInfiniteQuery,
|
| 437 |
+
buildInitiateMutation,
|
| 438 |
+
getRunningQueryThunk,
|
| 439 |
+
getRunningMutationThunk,
|
| 440 |
+
getRunningQueriesThunk,
|
| 441 |
+
getRunningMutationsThunk
|
| 442 |
+
};
|
| 443 |
+
function getRunningQueryThunk(endpointName, queryArgs) {
|
| 444 |
+
return (dispatch) => {
|
| 445 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 446 |
+
const queryCacheKey = serializeQueryArgs({
|
| 447 |
+
queryArgs,
|
| 448 |
+
endpointDefinition,
|
| 449 |
+
endpointName
|
| 450 |
+
});
|
| 451 |
+
return runningQueries.get(dispatch)?.[queryCacheKey];
|
| 452 |
+
};
|
| 453 |
+
}
|
| 454 |
+
function getRunningMutationThunk(_endpointName, fixedCacheKeyOrRequestId) {
|
| 455 |
+
return (dispatch) => {
|
| 456 |
+
return runningMutations.get(dispatch)?.[fixedCacheKeyOrRequestId];
|
| 457 |
+
};
|
| 458 |
+
}
|
| 459 |
+
function getRunningQueriesThunk() {
|
| 460 |
+
return (dispatch) => Object.values(runningQueries.get(dispatch) || {}).filter(isNotNullish);
|
| 461 |
+
}
|
| 462 |
+
function getRunningMutationsThunk() {
|
| 463 |
+
return (dispatch) => Object.values(runningMutations.get(dispatch) || {}).filter(isNotNullish);
|
| 464 |
+
}
|
| 465 |
+
function middlewareWarning(dispatch) {
|
| 466 |
+
if (process.env.NODE_ENV !== "production") {
|
| 467 |
+
if (middlewareWarning.triggered) return;
|
| 468 |
+
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
| 469 |
+
middlewareWarning.triggered = true;
|
| 470 |
+
if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
|
| 471 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage(34) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
|
| 472 |
+
You must add the middleware for RTK-Query to function correctly!`);
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
}
|
| 476 |
+
function buildInitiateAnyQuery(endpointName, endpointDefinition) {
|
| 477 |
+
const queryAction = (arg, {
|
| 478 |
+
subscribe = true,
|
| 479 |
+
forceRefetch,
|
| 480 |
+
subscriptionOptions,
|
| 481 |
+
[forceQueryFnSymbol]: forceQueryFn,
|
| 482 |
+
...rest
|
| 483 |
+
} = {}) => (dispatch, getState) => {
|
| 484 |
+
const queryCacheKey = serializeQueryArgs({
|
| 485 |
+
queryArgs: arg,
|
| 486 |
+
endpointDefinition,
|
| 487 |
+
endpointName
|
| 488 |
+
});
|
| 489 |
+
let thunk;
|
| 490 |
+
const commonThunkArgs = {
|
| 491 |
+
...rest,
|
| 492 |
+
type: "query",
|
| 493 |
+
subscribe,
|
| 494 |
+
forceRefetch,
|
| 495 |
+
subscriptionOptions,
|
| 496 |
+
endpointName,
|
| 497 |
+
originalArgs: arg,
|
| 498 |
+
queryCacheKey,
|
| 499 |
+
[forceQueryFnSymbol]: forceQueryFn
|
| 500 |
+
};
|
| 501 |
+
if (isQueryDefinition(endpointDefinition)) {
|
| 502 |
+
thunk = queryThunk(commonThunkArgs);
|
| 503 |
+
} else {
|
| 504 |
+
const {
|
| 505 |
+
direction,
|
| 506 |
+
initialPageParam
|
| 507 |
+
} = rest;
|
| 508 |
+
thunk = infiniteQueryThunk({
|
| 509 |
+
...commonThunkArgs,
|
| 510 |
+
// Supply these even if undefined. This helps with a field existence
|
| 511 |
+
// check over in `buildSlice.ts`
|
| 512 |
+
direction,
|
| 513 |
+
initialPageParam
|
| 514 |
+
});
|
| 515 |
+
}
|
| 516 |
+
const selector = api.endpoints[endpointName].select(arg);
|
| 517 |
+
const thunkResult = dispatch(thunk);
|
| 518 |
+
const stateAfter = selector(getState());
|
| 519 |
+
middlewareWarning(dispatch);
|
| 520 |
+
const {
|
| 521 |
+
requestId,
|
| 522 |
+
abort
|
| 523 |
+
} = thunkResult;
|
| 524 |
+
const skippedSynchronously = stateAfter.requestId !== requestId;
|
| 525 |
+
const runningQuery = runningQueries.get(dispatch)?.[queryCacheKey];
|
| 526 |
+
const selectFromState = () => selector(getState());
|
| 527 |
+
const statePromise = Object.assign(forceQueryFn ? (
|
| 528 |
+
// a query has been forced (upsertQueryData)
|
| 529 |
+
// -> we want to resolve it once data has been written with the data that will be written
|
| 530 |
+
thunkResult.then(selectFromState)
|
| 531 |
+
) : skippedSynchronously && !runningQuery ? (
|
| 532 |
+
// a query has been skipped due to a condition and we do not have any currently running query
|
| 533 |
+
// -> we want to resolve it immediately with the current data
|
| 534 |
+
Promise.resolve(stateAfter)
|
| 535 |
+
) : (
|
| 536 |
+
// query just started or one is already in flight
|
| 537 |
+
// -> wait for the running query, then resolve with data from after that
|
| 538 |
+
Promise.all([runningQuery, thunkResult]).then(selectFromState)
|
| 539 |
+
), {
|
| 540 |
+
arg,
|
| 541 |
+
requestId,
|
| 542 |
+
subscriptionOptions,
|
| 543 |
+
queryCacheKey,
|
| 544 |
+
abort,
|
| 545 |
+
async unwrap() {
|
| 546 |
+
const result = await statePromise;
|
| 547 |
+
if (result.isError) {
|
| 548 |
+
throw result.error;
|
| 549 |
+
}
|
| 550 |
+
return result.data;
|
| 551 |
+
},
|
| 552 |
+
refetch: () => dispatch(queryAction(arg, {
|
| 553 |
+
subscribe: false,
|
| 554 |
+
forceRefetch: true
|
| 555 |
+
})),
|
| 556 |
+
unsubscribe() {
|
| 557 |
+
if (subscribe) dispatch(unsubscribeQueryResult({
|
| 558 |
+
queryCacheKey,
|
| 559 |
+
requestId
|
| 560 |
+
}));
|
| 561 |
+
},
|
| 562 |
+
updateSubscriptionOptions(options) {
|
| 563 |
+
statePromise.subscriptionOptions = options;
|
| 564 |
+
dispatch(updateSubscriptionOptions({
|
| 565 |
+
endpointName,
|
| 566 |
+
requestId,
|
| 567 |
+
queryCacheKey,
|
| 568 |
+
options
|
| 569 |
+
}));
|
| 570 |
+
}
|
| 571 |
+
});
|
| 572 |
+
if (!runningQuery && !skippedSynchronously && !forceQueryFn) {
|
| 573 |
+
const running = getOrInsert(runningQueries, dispatch, {});
|
| 574 |
+
running[queryCacheKey] = statePromise;
|
| 575 |
+
statePromise.then(() => {
|
| 576 |
+
delete running[queryCacheKey];
|
| 577 |
+
if (!countObjectKeys(running)) {
|
| 578 |
+
runningQueries.delete(dispatch);
|
| 579 |
+
}
|
| 580 |
+
});
|
| 581 |
+
}
|
| 582 |
+
return statePromise;
|
| 583 |
+
};
|
| 584 |
+
return queryAction;
|
| 585 |
+
}
|
| 586 |
+
function buildInitiateQuery(endpointName, endpointDefinition) {
|
| 587 |
+
const queryAction = buildInitiateAnyQuery(endpointName, endpointDefinition);
|
| 588 |
+
return queryAction;
|
| 589 |
+
}
|
| 590 |
+
function buildInitiateInfiniteQuery(endpointName, endpointDefinition) {
|
| 591 |
+
const infiniteQueryAction = buildInitiateAnyQuery(endpointName, endpointDefinition);
|
| 592 |
+
return infiniteQueryAction;
|
| 593 |
+
}
|
| 594 |
+
function buildInitiateMutation(endpointName) {
|
| 595 |
+
return (arg, {
|
| 596 |
+
track = true,
|
| 597 |
+
fixedCacheKey
|
| 598 |
+
} = {}) => (dispatch, getState) => {
|
| 599 |
+
const thunk = mutationThunk({
|
| 600 |
+
type: "mutation",
|
| 601 |
+
endpointName,
|
| 602 |
+
originalArgs: arg,
|
| 603 |
+
track,
|
| 604 |
+
fixedCacheKey
|
| 605 |
+
});
|
| 606 |
+
const thunkResult = dispatch(thunk);
|
| 607 |
+
middlewareWarning(dispatch);
|
| 608 |
+
const {
|
| 609 |
+
requestId,
|
| 610 |
+
abort,
|
| 611 |
+
unwrap
|
| 612 |
+
} = thunkResult;
|
| 613 |
+
const returnValuePromise = asSafePromise(thunkResult.unwrap().then((data) => ({
|
| 614 |
+
data
|
| 615 |
+
})), (error) => ({
|
| 616 |
+
error
|
| 617 |
+
}));
|
| 618 |
+
const reset = () => {
|
| 619 |
+
dispatch(removeMutationResult({
|
| 620 |
+
requestId,
|
| 621 |
+
fixedCacheKey
|
| 622 |
+
}));
|
| 623 |
+
};
|
| 624 |
+
const ret = Object.assign(returnValuePromise, {
|
| 625 |
+
arg: thunkResult.arg,
|
| 626 |
+
requestId,
|
| 627 |
+
abort,
|
| 628 |
+
unwrap,
|
| 629 |
+
reset
|
| 630 |
+
});
|
| 631 |
+
const running = runningMutations.get(dispatch) || {};
|
| 632 |
+
runningMutations.set(dispatch, running);
|
| 633 |
+
running[requestId] = ret;
|
| 634 |
+
ret.then(() => {
|
| 635 |
+
delete running[requestId];
|
| 636 |
+
if (!countObjectKeys(running)) {
|
| 637 |
+
runningMutations.delete(dispatch);
|
| 638 |
+
}
|
| 639 |
+
});
|
| 640 |
+
if (fixedCacheKey) {
|
| 641 |
+
running[fixedCacheKey] = ret;
|
| 642 |
+
ret.then(() => {
|
| 643 |
+
if (running[fixedCacheKey] === ret) {
|
| 644 |
+
delete running[fixedCacheKey];
|
| 645 |
+
if (!countObjectKeys(running)) {
|
| 646 |
+
runningMutations.delete(dispatch);
|
| 647 |
+
}
|
| 648 |
+
}
|
| 649 |
+
});
|
| 650 |
+
}
|
| 651 |
+
return ret;
|
| 652 |
+
};
|
| 653 |
+
}
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
// src/query/standardSchema.ts
|
| 657 |
+
import { SchemaError } from "@standard-schema/utils";
|
| 658 |
+
var NamedSchemaError = class extends SchemaError {
|
| 659 |
+
constructor(issues, value, schemaName, _bqMeta) {
|
| 660 |
+
super(issues);
|
| 661 |
+
this.value = value;
|
| 662 |
+
this.schemaName = schemaName;
|
| 663 |
+
this._bqMeta = _bqMeta;
|
| 664 |
+
}
|
| 665 |
+
};
|
| 666 |
+
async function parseWithSchema(schema, data, schemaName, bqMeta) {
|
| 667 |
+
const result = await schema["~standard"].validate(data);
|
| 668 |
+
if (result.issues) {
|
| 669 |
+
throw new NamedSchemaError(result.issues, data, schemaName, bqMeta);
|
| 670 |
+
}
|
| 671 |
+
return result.value;
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
// src/query/core/buildThunks.ts
|
| 675 |
+
function defaultTransformResponse(baseQueryReturnValue) {
|
| 676 |
+
return baseQueryReturnValue;
|
| 677 |
+
}
|
| 678 |
+
var addShouldAutoBatch = (arg = {}) => {
|
| 679 |
+
return {
|
| 680 |
+
...arg,
|
| 681 |
+
[SHOULD_AUTOBATCH]: true
|
| 682 |
+
};
|
| 683 |
+
};
|
| 684 |
+
function buildThunks({
|
| 685 |
+
reducerPath,
|
| 686 |
+
baseQuery,
|
| 687 |
+
context: {
|
| 688 |
+
endpointDefinitions
|
| 689 |
+
},
|
| 690 |
+
serializeQueryArgs,
|
| 691 |
+
api,
|
| 692 |
+
assertTagType,
|
| 693 |
+
selectors,
|
| 694 |
+
onSchemaFailure,
|
| 695 |
+
catchSchemaFailure: globalCatchSchemaFailure,
|
| 696 |
+
skipSchemaValidation: globalSkipSchemaValidation
|
| 697 |
+
}) {
|
| 698 |
+
const patchQueryData = (endpointName, arg, patches, updateProvided) => (dispatch, getState) => {
|
| 699 |
+
const endpointDefinition = endpointDefinitions[endpointName];
|
| 700 |
+
const queryCacheKey = serializeQueryArgs({
|
| 701 |
+
queryArgs: arg,
|
| 702 |
+
endpointDefinition,
|
| 703 |
+
endpointName
|
| 704 |
+
});
|
| 705 |
+
dispatch(api.internalActions.queryResultPatched({
|
| 706 |
+
queryCacheKey,
|
| 707 |
+
patches
|
| 708 |
+
}));
|
| 709 |
+
if (!updateProvided) {
|
| 710 |
+
return;
|
| 711 |
+
}
|
| 712 |
+
const newValue = api.endpoints[endpointName].select(arg)(
|
| 713 |
+
// Work around TS 4.1 mismatch
|
| 714 |
+
getState()
|
| 715 |
+
);
|
| 716 |
+
const providedTags = calculateProvidedBy(endpointDefinition.providesTags, newValue.data, void 0, arg, {}, assertTagType);
|
| 717 |
+
dispatch(api.internalActions.updateProvidedBy([{
|
| 718 |
+
queryCacheKey,
|
| 719 |
+
providedTags
|
| 720 |
+
}]));
|
| 721 |
+
};
|
| 722 |
+
function addToStart(items, item, max = 0) {
|
| 723 |
+
const newItems = [item, ...items];
|
| 724 |
+
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
| 725 |
+
}
|
| 726 |
+
function addToEnd(items, item, max = 0) {
|
| 727 |
+
const newItems = [...items, item];
|
| 728 |
+
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
| 729 |
+
}
|
| 730 |
+
const updateQueryData = (endpointName, arg, updateRecipe, updateProvided = true) => (dispatch, getState) => {
|
| 731 |
+
const endpointDefinition = api.endpoints[endpointName];
|
| 732 |
+
const currentState = endpointDefinition.select(arg)(
|
| 733 |
+
// Work around TS 4.1 mismatch
|
| 734 |
+
getState()
|
| 735 |
+
);
|
| 736 |
+
const ret = {
|
| 737 |
+
patches: [],
|
| 738 |
+
inversePatches: [],
|
| 739 |
+
undo: () => dispatch(api.util.patchQueryData(endpointName, arg, ret.inversePatches, updateProvided))
|
| 740 |
+
};
|
| 741 |
+
if (currentState.status === "uninitialized" /* uninitialized */) {
|
| 742 |
+
return ret;
|
| 743 |
+
}
|
| 744 |
+
let newValue;
|
| 745 |
+
if ("data" in currentState) {
|
| 746 |
+
if (isDraftable(currentState.data)) {
|
| 747 |
+
const [value, patches, inversePatches] = produceWithPatches(currentState.data, updateRecipe);
|
| 748 |
+
ret.patches.push(...patches);
|
| 749 |
+
ret.inversePatches.push(...inversePatches);
|
| 750 |
+
newValue = value;
|
| 751 |
+
} else {
|
| 752 |
+
newValue = updateRecipe(currentState.data);
|
| 753 |
+
ret.patches.push({
|
| 754 |
+
op: "replace",
|
| 755 |
+
path: [],
|
| 756 |
+
value: newValue
|
| 757 |
+
});
|
| 758 |
+
ret.inversePatches.push({
|
| 759 |
+
op: "replace",
|
| 760 |
+
path: [],
|
| 761 |
+
value: currentState.data
|
| 762 |
+
});
|
| 763 |
+
}
|
| 764 |
+
}
|
| 765 |
+
if (ret.patches.length === 0) {
|
| 766 |
+
return ret;
|
| 767 |
+
}
|
| 768 |
+
dispatch(api.util.patchQueryData(endpointName, arg, ret.patches, updateProvided));
|
| 769 |
+
return ret;
|
| 770 |
+
};
|
| 771 |
+
const upsertQueryData = (endpointName, arg, value) => (dispatch) => {
|
| 772 |
+
const res = dispatch(api.endpoints[endpointName].initiate(arg, {
|
| 773 |
+
subscribe: false,
|
| 774 |
+
forceRefetch: true,
|
| 775 |
+
[forceQueryFnSymbol]: () => ({
|
| 776 |
+
data: value
|
| 777 |
+
})
|
| 778 |
+
}));
|
| 779 |
+
return res;
|
| 780 |
+
};
|
| 781 |
+
const getTransformCallbackForEndpoint = (endpointDefinition, transformFieldName) => {
|
| 782 |
+
return endpointDefinition.query && endpointDefinition[transformFieldName] ? endpointDefinition[transformFieldName] : defaultTransformResponse;
|
| 783 |
+
};
|
| 784 |
+
const executeEndpoint = async (arg, {
|
| 785 |
+
signal,
|
| 786 |
+
abort,
|
| 787 |
+
rejectWithValue,
|
| 788 |
+
fulfillWithValue,
|
| 789 |
+
dispatch,
|
| 790 |
+
getState,
|
| 791 |
+
extra
|
| 792 |
+
}) => {
|
| 793 |
+
const endpointDefinition = endpointDefinitions[arg.endpointName];
|
| 794 |
+
const {
|
| 795 |
+
metaSchema,
|
| 796 |
+
skipSchemaValidation = globalSkipSchemaValidation
|
| 797 |
+
} = endpointDefinition;
|
| 798 |
+
try {
|
| 799 |
+
let transformResponse = getTransformCallbackForEndpoint(endpointDefinition, "transformResponse");
|
| 800 |
+
const baseQueryApi = {
|
| 801 |
+
signal,
|
| 802 |
+
abort,
|
| 803 |
+
dispatch,
|
| 804 |
+
getState,
|
| 805 |
+
extra,
|
| 806 |
+
endpoint: arg.endpointName,
|
| 807 |
+
type: arg.type,
|
| 808 |
+
forced: arg.type === "query" ? isForcedQuery(arg, getState()) : void 0,
|
| 809 |
+
queryCacheKey: arg.type === "query" ? arg.queryCacheKey : void 0
|
| 810 |
+
};
|
| 811 |
+
const forceQueryFn = arg.type === "query" ? arg[forceQueryFnSymbol] : void 0;
|
| 812 |
+
let finalQueryReturnValue;
|
| 813 |
+
const fetchPage = async (data, param, maxPages, previous) => {
|
| 814 |
+
if (param == null && data.pages.length) {
|
| 815 |
+
return Promise.resolve({
|
| 816 |
+
data
|
| 817 |
+
});
|
| 818 |
+
}
|
| 819 |
+
const finalQueryArg = {
|
| 820 |
+
queryArg: arg.originalArgs,
|
| 821 |
+
pageParam: param
|
| 822 |
+
};
|
| 823 |
+
const pageResponse = await executeRequest(finalQueryArg);
|
| 824 |
+
const addTo = previous ? addToStart : addToEnd;
|
| 825 |
+
return {
|
| 826 |
+
data: {
|
| 827 |
+
pages: addTo(data.pages, pageResponse.data, maxPages),
|
| 828 |
+
pageParams: addTo(data.pageParams, param, maxPages)
|
| 829 |
+
},
|
| 830 |
+
meta: pageResponse.meta
|
| 831 |
+
};
|
| 832 |
+
};
|
| 833 |
+
async function executeRequest(finalQueryArg) {
|
| 834 |
+
let result;
|
| 835 |
+
const {
|
| 836 |
+
extraOptions,
|
| 837 |
+
argSchema,
|
| 838 |
+
rawResponseSchema,
|
| 839 |
+
responseSchema
|
| 840 |
+
} = endpointDefinition;
|
| 841 |
+
if (argSchema && !skipSchemaValidation) {
|
| 842 |
+
finalQueryArg = await parseWithSchema(
|
| 843 |
+
argSchema,
|
| 844 |
+
finalQueryArg,
|
| 845 |
+
"argSchema",
|
| 846 |
+
{}
|
| 847 |
+
// we don't have a meta yet, so we can't pass it
|
| 848 |
+
);
|
| 849 |
+
}
|
| 850 |
+
if (forceQueryFn) {
|
| 851 |
+
result = forceQueryFn();
|
| 852 |
+
} else if (endpointDefinition.query) {
|
| 853 |
+
result = await baseQuery(endpointDefinition.query(finalQueryArg), baseQueryApi, extraOptions);
|
| 854 |
+
} else {
|
| 855 |
+
result = await endpointDefinition.queryFn(finalQueryArg, baseQueryApi, extraOptions, (arg2) => baseQuery(arg2, baseQueryApi, extraOptions));
|
| 856 |
+
}
|
| 857 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
| 858 |
+
const what = endpointDefinition.query ? "`baseQuery`" : "`queryFn`";
|
| 859 |
+
let err;
|
| 860 |
+
if (!result) {
|
| 861 |
+
err = `${what} did not return anything.`;
|
| 862 |
+
} else if (typeof result !== "object") {
|
| 863 |
+
err = `${what} did not return an object.`;
|
| 864 |
+
} else if (result.error && result.data) {
|
| 865 |
+
err = `${what} returned an object containing both \`error\` and \`result\`.`;
|
| 866 |
+
} else if (result.error === void 0 && result.data === void 0) {
|
| 867 |
+
err = `${what} returned an object containing neither a valid \`error\` and \`result\`. At least one of them should not be \`undefined\``;
|
| 868 |
+
} else {
|
| 869 |
+
for (const key of Object.keys(result)) {
|
| 870 |
+
if (key !== "error" && key !== "data" && key !== "meta") {
|
| 871 |
+
err = `The object returned by ${what} has the unknown property ${key}.`;
|
| 872 |
+
break;
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
}
|
| 876 |
+
if (err) {
|
| 877 |
+
console.error(`Error encountered handling the endpoint ${arg.endpointName}.
|
| 878 |
+
${err}
|
| 879 |
+
It needs to return an object with either the shape \`{ data: <value> }\` or \`{ error: <value> }\` that may contain an optional \`meta\` property.
|
| 880 |
+
Object returned was:`, result);
|
| 881 |
+
}
|
| 882 |
+
}
|
| 883 |
+
if (result.error) throw new HandledError(result.error, result.meta);
|
| 884 |
+
let {
|
| 885 |
+
data
|
| 886 |
+
} = result;
|
| 887 |
+
if (rawResponseSchema && !skipSchemaValidation) {
|
| 888 |
+
data = await parseWithSchema(rawResponseSchema, result.data, "rawResponseSchema", result.meta);
|
| 889 |
+
}
|
| 890 |
+
let transformedResponse = await transformResponse(data, result.meta, finalQueryArg);
|
| 891 |
+
if (responseSchema && !skipSchemaValidation) {
|
| 892 |
+
transformedResponse = await parseWithSchema(responseSchema, transformedResponse, "responseSchema", result.meta);
|
| 893 |
+
}
|
| 894 |
+
return {
|
| 895 |
+
...result,
|
| 896 |
+
data: transformedResponse
|
| 897 |
+
};
|
| 898 |
+
}
|
| 899 |
+
if (arg.type === "query" && "infiniteQueryOptions" in endpointDefinition) {
|
| 900 |
+
const {
|
| 901 |
+
infiniteQueryOptions
|
| 902 |
+
} = endpointDefinition;
|
| 903 |
+
const {
|
| 904 |
+
maxPages = Infinity
|
| 905 |
+
} = infiniteQueryOptions;
|
| 906 |
+
let result;
|
| 907 |
+
const blankData = {
|
| 908 |
+
pages: [],
|
| 909 |
+
pageParams: []
|
| 910 |
+
};
|
| 911 |
+
const cachedData = selectors.selectQueryEntry(getState(), arg.queryCacheKey)?.data;
|
| 912 |
+
const isForcedQueryNeedingRefetch = (
|
| 913 |
+
// arg.forceRefetch
|
| 914 |
+
isForcedQuery(arg, getState()) && !arg.direction
|
| 915 |
+
);
|
| 916 |
+
const existingData = isForcedQueryNeedingRefetch || !cachedData ? blankData : cachedData;
|
| 917 |
+
if ("direction" in arg && arg.direction && existingData.pages.length) {
|
| 918 |
+
const previous = arg.direction === "backward";
|
| 919 |
+
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
| 920 |
+
const param = pageParamFn(infiniteQueryOptions, existingData, arg.originalArgs);
|
| 921 |
+
result = await fetchPage(existingData, param, maxPages, previous);
|
| 922 |
+
} else {
|
| 923 |
+
const {
|
| 924 |
+
initialPageParam = infiniteQueryOptions.initialPageParam
|
| 925 |
+
} = arg;
|
| 926 |
+
const cachedPageParams = cachedData?.pageParams ?? [];
|
| 927 |
+
const firstPageParam = cachedPageParams[0] ?? initialPageParam;
|
| 928 |
+
const totalPages = cachedPageParams.length;
|
| 929 |
+
result = await fetchPage(existingData, firstPageParam, maxPages);
|
| 930 |
+
if (forceQueryFn) {
|
| 931 |
+
result = {
|
| 932 |
+
data: result.data.pages[0]
|
| 933 |
+
};
|
| 934 |
+
}
|
| 935 |
+
for (let i = 1; i < totalPages; i++) {
|
| 936 |
+
const param = getNextPageParam(infiniteQueryOptions, result.data, arg.originalArgs);
|
| 937 |
+
result = await fetchPage(result.data, param, maxPages);
|
| 938 |
+
}
|
| 939 |
+
}
|
| 940 |
+
finalQueryReturnValue = result;
|
| 941 |
+
} else {
|
| 942 |
+
finalQueryReturnValue = await executeRequest(arg.originalArgs);
|
| 943 |
+
}
|
| 944 |
+
if (metaSchema && !skipSchemaValidation && finalQueryReturnValue.meta) {
|
| 945 |
+
finalQueryReturnValue.meta = await parseWithSchema(metaSchema, finalQueryReturnValue.meta, "metaSchema", finalQueryReturnValue.meta);
|
| 946 |
+
}
|
| 947 |
+
return fulfillWithValue(finalQueryReturnValue.data, addShouldAutoBatch({
|
| 948 |
+
fulfilledTimeStamp: Date.now(),
|
| 949 |
+
baseQueryMeta: finalQueryReturnValue.meta
|
| 950 |
+
}));
|
| 951 |
+
} catch (error) {
|
| 952 |
+
let caughtError = error;
|
| 953 |
+
if (caughtError instanceof HandledError) {
|
| 954 |
+
let transformErrorResponse = getTransformCallbackForEndpoint(endpointDefinition, "transformErrorResponse");
|
| 955 |
+
const {
|
| 956 |
+
rawErrorResponseSchema,
|
| 957 |
+
errorResponseSchema
|
| 958 |
+
} = endpointDefinition;
|
| 959 |
+
let {
|
| 960 |
+
value,
|
| 961 |
+
meta
|
| 962 |
+
} = caughtError;
|
| 963 |
+
try {
|
| 964 |
+
if (rawErrorResponseSchema && !skipSchemaValidation) {
|
| 965 |
+
value = await parseWithSchema(rawErrorResponseSchema, value, "rawErrorResponseSchema", meta);
|
| 966 |
+
}
|
| 967 |
+
if (metaSchema && !skipSchemaValidation) {
|
| 968 |
+
meta = await parseWithSchema(metaSchema, meta, "metaSchema", meta);
|
| 969 |
+
}
|
| 970 |
+
let transformedErrorResponse = await transformErrorResponse(value, meta, arg.originalArgs);
|
| 971 |
+
if (errorResponseSchema && !skipSchemaValidation) {
|
| 972 |
+
transformedErrorResponse = await parseWithSchema(errorResponseSchema, transformedErrorResponse, "errorResponseSchema", meta);
|
| 973 |
+
}
|
| 974 |
+
return rejectWithValue(transformedErrorResponse, addShouldAutoBatch({
|
| 975 |
+
baseQueryMeta: meta
|
| 976 |
+
}));
|
| 977 |
+
} catch (e) {
|
| 978 |
+
caughtError = e;
|
| 979 |
+
}
|
| 980 |
+
}
|
| 981 |
+
try {
|
| 982 |
+
if (caughtError instanceof NamedSchemaError) {
|
| 983 |
+
const info = {
|
| 984 |
+
endpoint: arg.endpointName,
|
| 985 |
+
arg: arg.originalArgs,
|
| 986 |
+
type: arg.type,
|
| 987 |
+
queryCacheKey: arg.type === "query" ? arg.queryCacheKey : void 0
|
| 988 |
+
};
|
| 989 |
+
endpointDefinition.onSchemaFailure?.(caughtError, info);
|
| 990 |
+
onSchemaFailure?.(caughtError, info);
|
| 991 |
+
const {
|
| 992 |
+
catchSchemaFailure = globalCatchSchemaFailure
|
| 993 |
+
} = endpointDefinition;
|
| 994 |
+
if (catchSchemaFailure) {
|
| 995 |
+
return rejectWithValue(catchSchemaFailure(caughtError, info), addShouldAutoBatch({
|
| 996 |
+
baseQueryMeta: caughtError._bqMeta
|
| 997 |
+
}));
|
| 998 |
+
}
|
| 999 |
+
}
|
| 1000 |
+
} catch (e) {
|
| 1001 |
+
caughtError = e;
|
| 1002 |
+
}
|
| 1003 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
|
| 1004 |
+
console.error(`An unhandled error occurred processing a request for the endpoint "${arg.endpointName}".
|
| 1005 |
+
In the case of an unhandled error, no tags will be "provided" or "invalidated".`, caughtError);
|
| 1006 |
+
} else {
|
| 1007 |
+
console.error(caughtError);
|
| 1008 |
+
}
|
| 1009 |
+
throw caughtError;
|
| 1010 |
+
}
|
| 1011 |
+
};
|
| 1012 |
+
function isForcedQuery(arg, state) {
|
| 1013 |
+
const requestState = selectors.selectQueryEntry(state, arg.queryCacheKey);
|
| 1014 |
+
const baseFetchOnMountOrArgChange = selectors.selectConfig(state).refetchOnMountOrArgChange;
|
| 1015 |
+
const fulfilledVal = requestState?.fulfilledTimeStamp;
|
| 1016 |
+
const refetchVal = arg.forceRefetch ?? (arg.subscribe && baseFetchOnMountOrArgChange);
|
| 1017 |
+
if (refetchVal) {
|
| 1018 |
+
return refetchVal === true || (Number(/* @__PURE__ */ new Date()) - Number(fulfilledVal)) / 1e3 >= refetchVal;
|
| 1019 |
+
}
|
| 1020 |
+
return false;
|
| 1021 |
+
}
|
| 1022 |
+
const createQueryThunk = () => {
|
| 1023 |
+
const generatedQueryThunk = createAsyncThunk(`${reducerPath}/executeQuery`, executeEndpoint, {
|
| 1024 |
+
getPendingMeta({
|
| 1025 |
+
arg
|
| 1026 |
+
}) {
|
| 1027 |
+
const endpointDefinition = endpointDefinitions[arg.endpointName];
|
| 1028 |
+
return addShouldAutoBatch({
|
| 1029 |
+
startedTimeStamp: Date.now(),
|
| 1030 |
+
...isInfiniteQueryDefinition(endpointDefinition) ? {
|
| 1031 |
+
direction: arg.direction
|
| 1032 |
+
} : {}
|
| 1033 |
+
});
|
| 1034 |
+
},
|
| 1035 |
+
condition(queryThunkArg, {
|
| 1036 |
+
getState
|
| 1037 |
+
}) {
|
| 1038 |
+
const state = getState();
|
| 1039 |
+
const requestState = selectors.selectQueryEntry(state, queryThunkArg.queryCacheKey);
|
| 1040 |
+
const fulfilledVal = requestState?.fulfilledTimeStamp;
|
| 1041 |
+
const currentArg = queryThunkArg.originalArgs;
|
| 1042 |
+
const previousArg = requestState?.originalArgs;
|
| 1043 |
+
const endpointDefinition = endpointDefinitions[queryThunkArg.endpointName];
|
| 1044 |
+
const direction = queryThunkArg.direction;
|
| 1045 |
+
if (isUpsertQuery(queryThunkArg)) {
|
| 1046 |
+
return true;
|
| 1047 |
+
}
|
| 1048 |
+
if (requestState?.status === "pending") {
|
| 1049 |
+
return false;
|
| 1050 |
+
}
|
| 1051 |
+
if (isForcedQuery(queryThunkArg, state)) {
|
| 1052 |
+
return true;
|
| 1053 |
+
}
|
| 1054 |
+
if (isQueryDefinition(endpointDefinition) && endpointDefinition?.forceRefetch?.({
|
| 1055 |
+
currentArg,
|
| 1056 |
+
previousArg,
|
| 1057 |
+
endpointState: requestState,
|
| 1058 |
+
state
|
| 1059 |
+
})) {
|
| 1060 |
+
return true;
|
| 1061 |
+
}
|
| 1062 |
+
if (fulfilledVal && !direction) {
|
| 1063 |
+
return false;
|
| 1064 |
+
}
|
| 1065 |
+
return true;
|
| 1066 |
+
},
|
| 1067 |
+
dispatchConditionRejection: true
|
| 1068 |
+
});
|
| 1069 |
+
return generatedQueryThunk;
|
| 1070 |
+
};
|
| 1071 |
+
const queryThunk = createQueryThunk();
|
| 1072 |
+
const infiniteQueryThunk = createQueryThunk();
|
| 1073 |
+
const mutationThunk = createAsyncThunk(`${reducerPath}/executeMutation`, executeEndpoint, {
|
| 1074 |
+
getPendingMeta() {
|
| 1075 |
+
return addShouldAutoBatch({
|
| 1076 |
+
startedTimeStamp: Date.now()
|
| 1077 |
+
});
|
| 1078 |
+
}
|
| 1079 |
+
});
|
| 1080 |
+
const hasTheForce = (options) => "force" in options;
|
| 1081 |
+
const hasMaxAge = (options) => "ifOlderThan" in options;
|
| 1082 |
+
const prefetch = (endpointName, arg, options) => (dispatch, getState) => {
|
| 1083 |
+
const force = hasTheForce(options) && options.force;
|
| 1084 |
+
const maxAge = hasMaxAge(options) && options.ifOlderThan;
|
| 1085 |
+
const queryAction = (force2 = true) => {
|
| 1086 |
+
const options2 = {
|
| 1087 |
+
forceRefetch: force2,
|
| 1088 |
+
isPrefetch: true
|
| 1089 |
+
};
|
| 1090 |
+
return api.endpoints[endpointName].initiate(arg, options2);
|
| 1091 |
+
};
|
| 1092 |
+
const latestStateValue = api.endpoints[endpointName].select(arg)(getState());
|
| 1093 |
+
if (force) {
|
| 1094 |
+
dispatch(queryAction());
|
| 1095 |
+
} else if (maxAge) {
|
| 1096 |
+
const lastFulfilledTs = latestStateValue?.fulfilledTimeStamp;
|
| 1097 |
+
if (!lastFulfilledTs) {
|
| 1098 |
+
dispatch(queryAction());
|
| 1099 |
+
return;
|
| 1100 |
+
}
|
| 1101 |
+
const shouldRetrigger = (Number(/* @__PURE__ */ new Date()) - Number(new Date(lastFulfilledTs))) / 1e3 >= maxAge;
|
| 1102 |
+
if (shouldRetrigger) {
|
| 1103 |
+
dispatch(queryAction());
|
| 1104 |
+
}
|
| 1105 |
+
} else {
|
| 1106 |
+
dispatch(queryAction(false));
|
| 1107 |
+
}
|
| 1108 |
+
};
|
| 1109 |
+
function matchesEndpoint(endpointName) {
|
| 1110 |
+
return (action) => action?.meta?.arg?.endpointName === endpointName;
|
| 1111 |
+
}
|
| 1112 |
+
function buildMatchThunkActions(thunk, endpointName) {
|
| 1113 |
+
return {
|
| 1114 |
+
matchPending: isAllOf(isPending(thunk), matchesEndpoint(endpointName)),
|
| 1115 |
+
matchFulfilled: isAllOf(isFulfilled(thunk), matchesEndpoint(endpointName)),
|
| 1116 |
+
matchRejected: isAllOf(isRejected(thunk), matchesEndpoint(endpointName))
|
| 1117 |
+
};
|
| 1118 |
+
}
|
| 1119 |
+
return {
|
| 1120 |
+
queryThunk,
|
| 1121 |
+
mutationThunk,
|
| 1122 |
+
infiniteQueryThunk,
|
| 1123 |
+
prefetch,
|
| 1124 |
+
updateQueryData,
|
| 1125 |
+
upsertQueryData,
|
| 1126 |
+
patchQueryData,
|
| 1127 |
+
buildMatchThunkActions
|
| 1128 |
+
};
|
| 1129 |
+
}
|
| 1130 |
+
function getNextPageParam(options, {
|
| 1131 |
+
pages,
|
| 1132 |
+
pageParams
|
| 1133 |
+
}, queryArg) {
|
| 1134 |
+
const lastIndex = pages.length - 1;
|
| 1135 |
+
return options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams, queryArg);
|
| 1136 |
+
}
|
| 1137 |
+
function getPreviousPageParam(options, {
|
| 1138 |
+
pages,
|
| 1139 |
+
pageParams
|
| 1140 |
+
}, queryArg) {
|
| 1141 |
+
return options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams, queryArg);
|
| 1142 |
+
}
|
| 1143 |
+
function calculateProvidedByThunk(action, type, endpointDefinitions, assertTagType) {
|
| 1144 |
+
return calculateProvidedBy(endpointDefinitions[action.meta.arg.endpointName][type], isFulfilled(action) ? action.payload : void 0, isRejectedWithValue(action) ? action.payload : void 0, action.meta.arg.originalArgs, "baseQueryMeta" in action.meta ? action.meta.baseQueryMeta : void 0, assertTagType);
|
| 1145 |
+
}
|
| 1146 |
+
|
| 1147 |
+
// src/query/core/buildSlice.ts
|
| 1148 |
+
import { isDraft } from "immer";
|
| 1149 |
+
import { applyPatches, original } from "immer";
|
| 1150 |
+
function updateQuerySubstateIfExists(state, queryCacheKey, update) {
|
| 1151 |
+
const substate = state[queryCacheKey];
|
| 1152 |
+
if (substate) {
|
| 1153 |
+
update(substate);
|
| 1154 |
+
}
|
| 1155 |
+
}
|
| 1156 |
+
function getMutationCacheKey(id) {
|
| 1157 |
+
return ("arg" in id ? id.arg.fixedCacheKey : id.fixedCacheKey) ?? id.requestId;
|
| 1158 |
+
}
|
| 1159 |
+
function updateMutationSubstateIfExists(state, id, update) {
|
| 1160 |
+
const substate = state[getMutationCacheKey(id)];
|
| 1161 |
+
if (substate) {
|
| 1162 |
+
update(substate);
|
| 1163 |
+
}
|
| 1164 |
+
}
|
| 1165 |
+
var initialState = {};
|
| 1166 |
+
function buildSlice({
|
| 1167 |
+
reducerPath,
|
| 1168 |
+
queryThunk,
|
| 1169 |
+
mutationThunk,
|
| 1170 |
+
serializeQueryArgs,
|
| 1171 |
+
context: {
|
| 1172 |
+
endpointDefinitions: definitions,
|
| 1173 |
+
apiUid,
|
| 1174 |
+
extractRehydrationInfo,
|
| 1175 |
+
hasRehydrationInfo
|
| 1176 |
+
},
|
| 1177 |
+
assertTagType,
|
| 1178 |
+
config
|
| 1179 |
+
}) {
|
| 1180 |
+
const resetApiState = createAction(`${reducerPath}/resetApiState`);
|
| 1181 |
+
function writePendingCacheEntry(draft, arg, upserting, meta) {
|
| 1182 |
+
draft[arg.queryCacheKey] ??= {
|
| 1183 |
+
status: "uninitialized" /* uninitialized */,
|
| 1184 |
+
endpointName: arg.endpointName
|
| 1185 |
+
};
|
| 1186 |
+
updateQuerySubstateIfExists(draft, arg.queryCacheKey, (substate) => {
|
| 1187 |
+
substate.status = "pending" /* pending */;
|
| 1188 |
+
substate.requestId = upserting && substate.requestId ? (
|
| 1189 |
+
// for `upsertQuery` **updates**, keep the current `requestId`
|
| 1190 |
+
substate.requestId
|
| 1191 |
+
) : (
|
| 1192 |
+
// for normal queries or `upsertQuery` **inserts** always update the `requestId`
|
| 1193 |
+
meta.requestId
|
| 1194 |
+
);
|
| 1195 |
+
if (arg.originalArgs !== void 0) {
|
| 1196 |
+
substate.originalArgs = arg.originalArgs;
|
| 1197 |
+
}
|
| 1198 |
+
substate.startedTimeStamp = meta.startedTimeStamp;
|
| 1199 |
+
const endpointDefinition = definitions[meta.arg.endpointName];
|
| 1200 |
+
if (isInfiniteQueryDefinition(endpointDefinition) && "direction" in arg) {
|
| 1201 |
+
;
|
| 1202 |
+
substate.direction = arg.direction;
|
| 1203 |
+
}
|
| 1204 |
+
});
|
| 1205 |
+
}
|
| 1206 |
+
function writeFulfilledCacheEntry(draft, meta, payload, upserting) {
|
| 1207 |
+
updateQuerySubstateIfExists(draft, meta.arg.queryCacheKey, (substate) => {
|
| 1208 |
+
if (substate.requestId !== meta.requestId && !upserting) return;
|
| 1209 |
+
const {
|
| 1210 |
+
merge
|
| 1211 |
+
} = definitions[meta.arg.endpointName];
|
| 1212 |
+
substate.status = "fulfilled" /* fulfilled */;
|
| 1213 |
+
if (merge) {
|
| 1214 |
+
if (substate.data !== void 0) {
|
| 1215 |
+
const {
|
| 1216 |
+
fulfilledTimeStamp,
|
| 1217 |
+
arg,
|
| 1218 |
+
baseQueryMeta,
|
| 1219 |
+
requestId
|
| 1220 |
+
} = meta;
|
| 1221 |
+
let newData = createNextState(substate.data, (draftSubstateData) => {
|
| 1222 |
+
return merge(draftSubstateData, payload, {
|
| 1223 |
+
arg: arg.originalArgs,
|
| 1224 |
+
baseQueryMeta,
|
| 1225 |
+
fulfilledTimeStamp,
|
| 1226 |
+
requestId
|
| 1227 |
+
});
|
| 1228 |
+
});
|
| 1229 |
+
substate.data = newData;
|
| 1230 |
+
} else {
|
| 1231 |
+
substate.data = payload;
|
| 1232 |
+
}
|
| 1233 |
+
} else {
|
| 1234 |
+
substate.data = definitions[meta.arg.endpointName].structuralSharing ?? true ? copyWithStructuralSharing(isDraft(substate.data) ? original(substate.data) : substate.data, payload) : payload;
|
| 1235 |
+
}
|
| 1236 |
+
delete substate.error;
|
| 1237 |
+
substate.fulfilledTimeStamp = meta.fulfilledTimeStamp;
|
| 1238 |
+
});
|
| 1239 |
+
}
|
| 1240 |
+
const querySlice = createSlice({
|
| 1241 |
+
name: `${reducerPath}/queries`,
|
| 1242 |
+
initialState,
|
| 1243 |
+
reducers: {
|
| 1244 |
+
removeQueryResult: {
|
| 1245 |
+
reducer(draft, {
|
| 1246 |
+
payload: {
|
| 1247 |
+
queryCacheKey
|
| 1248 |
+
}
|
| 1249 |
+
}) {
|
| 1250 |
+
delete draft[queryCacheKey];
|
| 1251 |
+
},
|
| 1252 |
+
prepare: prepareAutoBatched()
|
| 1253 |
+
},
|
| 1254 |
+
cacheEntriesUpserted: {
|
| 1255 |
+
reducer(draft, action) {
|
| 1256 |
+
for (const entry of action.payload) {
|
| 1257 |
+
const {
|
| 1258 |
+
queryDescription: arg,
|
| 1259 |
+
value
|
| 1260 |
+
} = entry;
|
| 1261 |
+
writePendingCacheEntry(draft, arg, true, {
|
| 1262 |
+
arg,
|
| 1263 |
+
requestId: action.meta.requestId,
|
| 1264 |
+
startedTimeStamp: action.meta.timestamp
|
| 1265 |
+
});
|
| 1266 |
+
writeFulfilledCacheEntry(
|
| 1267 |
+
draft,
|
| 1268 |
+
{
|
| 1269 |
+
arg,
|
| 1270 |
+
requestId: action.meta.requestId,
|
| 1271 |
+
fulfilledTimeStamp: action.meta.timestamp,
|
| 1272 |
+
baseQueryMeta: {}
|
| 1273 |
+
},
|
| 1274 |
+
value,
|
| 1275 |
+
// We know we're upserting here
|
| 1276 |
+
true
|
| 1277 |
+
);
|
| 1278 |
+
}
|
| 1279 |
+
},
|
| 1280 |
+
prepare: (payload) => {
|
| 1281 |
+
const queryDescriptions = payload.map((entry) => {
|
| 1282 |
+
const {
|
| 1283 |
+
endpointName,
|
| 1284 |
+
arg,
|
| 1285 |
+
value
|
| 1286 |
+
} = entry;
|
| 1287 |
+
const endpointDefinition = definitions[endpointName];
|
| 1288 |
+
const queryDescription = {
|
| 1289 |
+
type: "query",
|
| 1290 |
+
endpointName,
|
| 1291 |
+
originalArgs: entry.arg,
|
| 1292 |
+
queryCacheKey: serializeQueryArgs({
|
| 1293 |
+
queryArgs: arg,
|
| 1294 |
+
endpointDefinition,
|
| 1295 |
+
endpointName
|
| 1296 |
+
})
|
| 1297 |
+
};
|
| 1298 |
+
return {
|
| 1299 |
+
queryDescription,
|
| 1300 |
+
value
|
| 1301 |
+
};
|
| 1302 |
+
});
|
| 1303 |
+
const result = {
|
| 1304 |
+
payload: queryDescriptions,
|
| 1305 |
+
meta: {
|
| 1306 |
+
[SHOULD_AUTOBATCH]: true,
|
| 1307 |
+
requestId: nanoid(),
|
| 1308 |
+
timestamp: Date.now()
|
| 1309 |
+
}
|
| 1310 |
+
};
|
| 1311 |
+
return result;
|
| 1312 |
+
}
|
| 1313 |
+
},
|
| 1314 |
+
queryResultPatched: {
|
| 1315 |
+
reducer(draft, {
|
| 1316 |
+
payload: {
|
| 1317 |
+
queryCacheKey,
|
| 1318 |
+
patches
|
| 1319 |
+
}
|
| 1320 |
+
}) {
|
| 1321 |
+
updateQuerySubstateIfExists(draft, queryCacheKey, (substate) => {
|
| 1322 |
+
substate.data = applyPatches(substate.data, patches.concat());
|
| 1323 |
+
});
|
| 1324 |
+
},
|
| 1325 |
+
prepare: prepareAutoBatched()
|
| 1326 |
+
}
|
| 1327 |
+
},
|
| 1328 |
+
extraReducers(builder) {
|
| 1329 |
+
builder.addCase(queryThunk.pending, (draft, {
|
| 1330 |
+
meta,
|
| 1331 |
+
meta: {
|
| 1332 |
+
arg
|
| 1333 |
+
}
|
| 1334 |
+
}) => {
|
| 1335 |
+
const upserting = isUpsertQuery(arg);
|
| 1336 |
+
writePendingCacheEntry(draft, arg, upserting, meta);
|
| 1337 |
+
}).addCase(queryThunk.fulfilled, (draft, {
|
| 1338 |
+
meta,
|
| 1339 |
+
payload
|
| 1340 |
+
}) => {
|
| 1341 |
+
const upserting = isUpsertQuery(meta.arg);
|
| 1342 |
+
writeFulfilledCacheEntry(draft, meta, payload, upserting);
|
| 1343 |
+
}).addCase(queryThunk.rejected, (draft, {
|
| 1344 |
+
meta: {
|
| 1345 |
+
condition,
|
| 1346 |
+
arg,
|
| 1347 |
+
requestId
|
| 1348 |
+
},
|
| 1349 |
+
error,
|
| 1350 |
+
payload
|
| 1351 |
+
}) => {
|
| 1352 |
+
updateQuerySubstateIfExists(draft, arg.queryCacheKey, (substate) => {
|
| 1353 |
+
if (condition) {
|
| 1354 |
+
} else {
|
| 1355 |
+
if (substate.requestId !== requestId) return;
|
| 1356 |
+
substate.status = "rejected" /* rejected */;
|
| 1357 |
+
substate.error = payload ?? error;
|
| 1358 |
+
}
|
| 1359 |
+
});
|
| 1360 |
+
}).addMatcher(hasRehydrationInfo, (draft, action) => {
|
| 1361 |
+
const {
|
| 1362 |
+
queries
|
| 1363 |
+
} = extractRehydrationInfo(action);
|
| 1364 |
+
for (const [key, entry] of Object.entries(queries)) {
|
| 1365 |
+
if (
|
| 1366 |
+
// do not rehydrate entries that were currently in flight.
|
| 1367 |
+
entry?.status === "fulfilled" /* fulfilled */ || entry?.status === "rejected" /* rejected */
|
| 1368 |
+
) {
|
| 1369 |
+
draft[key] = entry;
|
| 1370 |
+
}
|
| 1371 |
+
}
|
| 1372 |
+
});
|
| 1373 |
+
}
|
| 1374 |
+
});
|
| 1375 |
+
const mutationSlice = createSlice({
|
| 1376 |
+
name: `${reducerPath}/mutations`,
|
| 1377 |
+
initialState,
|
| 1378 |
+
reducers: {
|
| 1379 |
+
removeMutationResult: {
|
| 1380 |
+
reducer(draft, {
|
| 1381 |
+
payload
|
| 1382 |
+
}) {
|
| 1383 |
+
const cacheKey = getMutationCacheKey(payload);
|
| 1384 |
+
if (cacheKey in draft) {
|
| 1385 |
+
delete draft[cacheKey];
|
| 1386 |
+
}
|
| 1387 |
+
},
|
| 1388 |
+
prepare: prepareAutoBatched()
|
| 1389 |
+
}
|
| 1390 |
+
},
|
| 1391 |
+
extraReducers(builder) {
|
| 1392 |
+
builder.addCase(mutationThunk.pending, (draft, {
|
| 1393 |
+
meta,
|
| 1394 |
+
meta: {
|
| 1395 |
+
requestId,
|
| 1396 |
+
arg,
|
| 1397 |
+
startedTimeStamp
|
| 1398 |
+
}
|
| 1399 |
+
}) => {
|
| 1400 |
+
if (!arg.track) return;
|
| 1401 |
+
draft[getMutationCacheKey(meta)] = {
|
| 1402 |
+
requestId,
|
| 1403 |
+
status: "pending" /* pending */,
|
| 1404 |
+
endpointName: arg.endpointName,
|
| 1405 |
+
startedTimeStamp
|
| 1406 |
+
};
|
| 1407 |
+
}).addCase(mutationThunk.fulfilled, (draft, {
|
| 1408 |
+
payload,
|
| 1409 |
+
meta
|
| 1410 |
+
}) => {
|
| 1411 |
+
if (!meta.arg.track) return;
|
| 1412 |
+
updateMutationSubstateIfExists(draft, meta, (substate) => {
|
| 1413 |
+
if (substate.requestId !== meta.requestId) return;
|
| 1414 |
+
substate.status = "fulfilled" /* fulfilled */;
|
| 1415 |
+
substate.data = payload;
|
| 1416 |
+
substate.fulfilledTimeStamp = meta.fulfilledTimeStamp;
|
| 1417 |
+
});
|
| 1418 |
+
}).addCase(mutationThunk.rejected, (draft, {
|
| 1419 |
+
payload,
|
| 1420 |
+
error,
|
| 1421 |
+
meta
|
| 1422 |
+
}) => {
|
| 1423 |
+
if (!meta.arg.track) return;
|
| 1424 |
+
updateMutationSubstateIfExists(draft, meta, (substate) => {
|
| 1425 |
+
if (substate.requestId !== meta.requestId) return;
|
| 1426 |
+
substate.status = "rejected" /* rejected */;
|
| 1427 |
+
substate.error = payload ?? error;
|
| 1428 |
+
});
|
| 1429 |
+
}).addMatcher(hasRehydrationInfo, (draft, action) => {
|
| 1430 |
+
const {
|
| 1431 |
+
mutations
|
| 1432 |
+
} = extractRehydrationInfo(action);
|
| 1433 |
+
for (const [key, entry] of Object.entries(mutations)) {
|
| 1434 |
+
if (
|
| 1435 |
+
// do not rehydrate entries that were currently in flight.
|
| 1436 |
+
(entry?.status === "fulfilled" /* fulfilled */ || entry?.status === "rejected" /* rejected */) && // only rehydrate endpoints that were persisted using a `fixedCacheKey`
|
| 1437 |
+
key !== entry?.requestId
|
| 1438 |
+
) {
|
| 1439 |
+
draft[key] = entry;
|
| 1440 |
+
}
|
| 1441 |
+
}
|
| 1442 |
+
});
|
| 1443 |
+
}
|
| 1444 |
+
});
|
| 1445 |
+
const initialInvalidationState = {
|
| 1446 |
+
tags: {},
|
| 1447 |
+
keys: {}
|
| 1448 |
+
};
|
| 1449 |
+
const invalidationSlice = createSlice({
|
| 1450 |
+
name: `${reducerPath}/invalidation`,
|
| 1451 |
+
initialState: initialInvalidationState,
|
| 1452 |
+
reducers: {
|
| 1453 |
+
updateProvidedBy: {
|
| 1454 |
+
reducer(draft, action) {
|
| 1455 |
+
for (const {
|
| 1456 |
+
queryCacheKey,
|
| 1457 |
+
providedTags
|
| 1458 |
+
} of action.payload) {
|
| 1459 |
+
removeCacheKeyFromTags(draft, queryCacheKey);
|
| 1460 |
+
for (const {
|
| 1461 |
+
type,
|
| 1462 |
+
id
|
| 1463 |
+
} of providedTags) {
|
| 1464 |
+
const subscribedQueries = (draft.tags[type] ??= {})[id || "__internal_without_id"] ??= [];
|
| 1465 |
+
const alreadySubscribed = subscribedQueries.includes(queryCacheKey);
|
| 1466 |
+
if (!alreadySubscribed) {
|
| 1467 |
+
subscribedQueries.push(queryCacheKey);
|
| 1468 |
+
}
|
| 1469 |
+
}
|
| 1470 |
+
draft.keys[queryCacheKey] = providedTags;
|
| 1471 |
+
}
|
| 1472 |
+
},
|
| 1473 |
+
prepare: prepareAutoBatched()
|
| 1474 |
+
}
|
| 1475 |
+
},
|
| 1476 |
+
extraReducers(builder) {
|
| 1477 |
+
builder.addCase(querySlice.actions.removeQueryResult, (draft, {
|
| 1478 |
+
payload: {
|
| 1479 |
+
queryCacheKey
|
| 1480 |
+
}
|
| 1481 |
+
}) => {
|
| 1482 |
+
removeCacheKeyFromTags(draft, queryCacheKey);
|
| 1483 |
+
}).addMatcher(hasRehydrationInfo, (draft, action) => {
|
| 1484 |
+
const {
|
| 1485 |
+
provided
|
| 1486 |
+
} = extractRehydrationInfo(action);
|
| 1487 |
+
for (const [type, incomingTags] of Object.entries(provided)) {
|
| 1488 |
+
for (const [id, cacheKeys] of Object.entries(incomingTags)) {
|
| 1489 |
+
const subscribedQueries = (draft.tags[type] ??= {})[id || "__internal_without_id"] ??= [];
|
| 1490 |
+
for (const queryCacheKey of cacheKeys) {
|
| 1491 |
+
const alreadySubscribed = subscribedQueries.includes(queryCacheKey);
|
| 1492 |
+
if (!alreadySubscribed) {
|
| 1493 |
+
subscribedQueries.push(queryCacheKey);
|
| 1494 |
+
}
|
| 1495 |
+
}
|
| 1496 |
+
}
|
| 1497 |
+
}
|
| 1498 |
+
}).addMatcher(isAnyOf(isFulfilled(queryThunk), isRejectedWithValue(queryThunk)), (draft, action) => {
|
| 1499 |
+
writeProvidedTagsForQueries(draft, [action]);
|
| 1500 |
+
}).addMatcher(querySlice.actions.cacheEntriesUpserted.match, (draft, action) => {
|
| 1501 |
+
const mockActions = action.payload.map(({
|
| 1502 |
+
queryDescription,
|
| 1503 |
+
value
|
| 1504 |
+
}) => {
|
| 1505 |
+
return {
|
| 1506 |
+
type: "UNKNOWN",
|
| 1507 |
+
payload: value,
|
| 1508 |
+
meta: {
|
| 1509 |
+
requestStatus: "fulfilled",
|
| 1510 |
+
requestId: "UNKNOWN",
|
| 1511 |
+
arg: queryDescription
|
| 1512 |
+
}
|
| 1513 |
+
};
|
| 1514 |
+
});
|
| 1515 |
+
writeProvidedTagsForQueries(draft, mockActions);
|
| 1516 |
+
});
|
| 1517 |
+
}
|
| 1518 |
+
});
|
| 1519 |
+
function removeCacheKeyFromTags(draft, queryCacheKey) {
|
| 1520 |
+
const existingTags = draft.keys[queryCacheKey] ?? [];
|
| 1521 |
+
for (const tag of existingTags) {
|
| 1522 |
+
const tagType = tag.type;
|
| 1523 |
+
const tagId = tag.id ?? "__internal_without_id";
|
| 1524 |
+
const tagSubscriptions = draft.tags[tagType]?.[tagId];
|
| 1525 |
+
if (tagSubscriptions) {
|
| 1526 |
+
draft.tags[tagType][tagId] = tagSubscriptions.filter((qc) => qc !== queryCacheKey);
|
| 1527 |
+
}
|
| 1528 |
+
}
|
| 1529 |
+
delete draft.keys[queryCacheKey];
|
| 1530 |
+
}
|
| 1531 |
+
function writeProvidedTagsForQueries(draft, actions2) {
|
| 1532 |
+
const providedByEntries = actions2.map((action) => {
|
| 1533 |
+
const providedTags = calculateProvidedByThunk(action, "providesTags", definitions, assertTagType);
|
| 1534 |
+
const {
|
| 1535 |
+
queryCacheKey
|
| 1536 |
+
} = action.meta.arg;
|
| 1537 |
+
return {
|
| 1538 |
+
queryCacheKey,
|
| 1539 |
+
providedTags
|
| 1540 |
+
};
|
| 1541 |
+
});
|
| 1542 |
+
invalidationSlice.caseReducers.updateProvidedBy(draft, invalidationSlice.actions.updateProvidedBy(providedByEntries));
|
| 1543 |
+
}
|
| 1544 |
+
const subscriptionSlice = createSlice({
|
| 1545 |
+
name: `${reducerPath}/subscriptions`,
|
| 1546 |
+
initialState,
|
| 1547 |
+
reducers: {
|
| 1548 |
+
updateSubscriptionOptions(d, a) {
|
| 1549 |
+
},
|
| 1550 |
+
unsubscribeQueryResult(d, a) {
|
| 1551 |
+
},
|
| 1552 |
+
internal_getRTKQSubscriptions() {
|
| 1553 |
+
}
|
| 1554 |
+
}
|
| 1555 |
+
});
|
| 1556 |
+
const internalSubscriptionsSlice = createSlice({
|
| 1557 |
+
name: `${reducerPath}/internalSubscriptions`,
|
| 1558 |
+
initialState,
|
| 1559 |
+
reducers: {
|
| 1560 |
+
subscriptionsUpdated: {
|
| 1561 |
+
reducer(state, action) {
|
| 1562 |
+
return applyPatches(state, action.payload);
|
| 1563 |
+
},
|
| 1564 |
+
prepare: prepareAutoBatched()
|
| 1565 |
+
}
|
| 1566 |
+
}
|
| 1567 |
+
});
|
| 1568 |
+
const configSlice = createSlice({
|
| 1569 |
+
name: `${reducerPath}/config`,
|
| 1570 |
+
initialState: {
|
| 1571 |
+
online: isOnline(),
|
| 1572 |
+
focused: isDocumentVisible(),
|
| 1573 |
+
middlewareRegistered: false,
|
| 1574 |
+
...config
|
| 1575 |
+
},
|
| 1576 |
+
reducers: {
|
| 1577 |
+
middlewareRegistered(state, {
|
| 1578 |
+
payload
|
| 1579 |
+
}) {
|
| 1580 |
+
state.middlewareRegistered = state.middlewareRegistered === "conflict" || apiUid !== payload ? "conflict" : true;
|
| 1581 |
+
}
|
| 1582 |
+
},
|
| 1583 |
+
extraReducers: (builder) => {
|
| 1584 |
+
builder.addCase(onOnline, (state) => {
|
| 1585 |
+
state.online = true;
|
| 1586 |
+
}).addCase(onOffline, (state) => {
|
| 1587 |
+
state.online = false;
|
| 1588 |
+
}).addCase(onFocus, (state) => {
|
| 1589 |
+
state.focused = true;
|
| 1590 |
+
}).addCase(onFocusLost, (state) => {
|
| 1591 |
+
state.focused = false;
|
| 1592 |
+
}).addMatcher(hasRehydrationInfo, (draft) => ({
|
| 1593 |
+
...draft
|
| 1594 |
+
}));
|
| 1595 |
+
}
|
| 1596 |
+
});
|
| 1597 |
+
const combinedReducer = combineReducers({
|
| 1598 |
+
queries: querySlice.reducer,
|
| 1599 |
+
mutations: mutationSlice.reducer,
|
| 1600 |
+
provided: invalidationSlice.reducer,
|
| 1601 |
+
subscriptions: internalSubscriptionsSlice.reducer,
|
| 1602 |
+
config: configSlice.reducer
|
| 1603 |
+
});
|
| 1604 |
+
const reducer = (state, action) => combinedReducer(resetApiState.match(action) ? void 0 : state, action);
|
| 1605 |
+
const actions = {
|
| 1606 |
+
...configSlice.actions,
|
| 1607 |
+
...querySlice.actions,
|
| 1608 |
+
...subscriptionSlice.actions,
|
| 1609 |
+
...internalSubscriptionsSlice.actions,
|
| 1610 |
+
...mutationSlice.actions,
|
| 1611 |
+
...invalidationSlice.actions,
|
| 1612 |
+
resetApiState
|
| 1613 |
+
};
|
| 1614 |
+
return {
|
| 1615 |
+
reducer,
|
| 1616 |
+
actions
|
| 1617 |
+
};
|
| 1618 |
+
}
|
| 1619 |
+
|
| 1620 |
+
// src/query/core/buildSelectors.ts
|
| 1621 |
+
var skipToken = /* @__PURE__ */ Symbol.for("RTKQ/skipToken");
|
| 1622 |
+
var initialSubState = {
|
| 1623 |
+
status: "uninitialized" /* uninitialized */
|
| 1624 |
+
};
|
| 1625 |
+
var defaultQuerySubState = /* @__PURE__ */ createNextState(initialSubState, () => {
|
| 1626 |
+
});
|
| 1627 |
+
var defaultMutationSubState = /* @__PURE__ */ createNextState(initialSubState, () => {
|
| 1628 |
+
});
|
| 1629 |
+
function buildSelectors({
|
| 1630 |
+
serializeQueryArgs,
|
| 1631 |
+
reducerPath,
|
| 1632 |
+
createSelector: createSelector2
|
| 1633 |
+
}) {
|
| 1634 |
+
const selectSkippedQuery = (state) => defaultQuerySubState;
|
| 1635 |
+
const selectSkippedMutation = (state) => defaultMutationSubState;
|
| 1636 |
+
return {
|
| 1637 |
+
buildQuerySelector,
|
| 1638 |
+
buildInfiniteQuerySelector,
|
| 1639 |
+
buildMutationSelector,
|
| 1640 |
+
selectInvalidatedBy,
|
| 1641 |
+
selectCachedArgsForQuery,
|
| 1642 |
+
selectApiState,
|
| 1643 |
+
selectQueries,
|
| 1644 |
+
selectMutations,
|
| 1645 |
+
selectQueryEntry,
|
| 1646 |
+
selectConfig
|
| 1647 |
+
};
|
| 1648 |
+
function withRequestFlags(substate) {
|
| 1649 |
+
return {
|
| 1650 |
+
...substate,
|
| 1651 |
+
...getRequestStatusFlags(substate.status)
|
| 1652 |
+
};
|
| 1653 |
+
}
|
| 1654 |
+
function selectApiState(rootState) {
|
| 1655 |
+
const state = rootState[reducerPath];
|
| 1656 |
+
if (process.env.NODE_ENV !== "production") {
|
| 1657 |
+
if (!state) {
|
| 1658 |
+
if (selectApiState.triggered) return state;
|
| 1659 |
+
selectApiState.triggered = true;
|
| 1660 |
+
console.error(`Error: No data found at \`state.${reducerPath}\`. Did you forget to add the reducer to the store?`);
|
| 1661 |
+
}
|
| 1662 |
+
}
|
| 1663 |
+
return state;
|
| 1664 |
+
}
|
| 1665 |
+
function selectQueries(rootState) {
|
| 1666 |
+
return selectApiState(rootState)?.queries;
|
| 1667 |
+
}
|
| 1668 |
+
function selectQueryEntry(rootState, cacheKey) {
|
| 1669 |
+
return selectQueries(rootState)?.[cacheKey];
|
| 1670 |
+
}
|
| 1671 |
+
function selectMutations(rootState) {
|
| 1672 |
+
return selectApiState(rootState)?.mutations;
|
| 1673 |
+
}
|
| 1674 |
+
function selectConfig(rootState) {
|
| 1675 |
+
return selectApiState(rootState)?.config;
|
| 1676 |
+
}
|
| 1677 |
+
function buildAnyQuerySelector(endpointName, endpointDefinition, combiner) {
|
| 1678 |
+
return (queryArgs) => {
|
| 1679 |
+
if (queryArgs === skipToken) {
|
| 1680 |
+
return createSelector2(selectSkippedQuery, combiner);
|
| 1681 |
+
}
|
| 1682 |
+
const serializedArgs = serializeQueryArgs({
|
| 1683 |
+
queryArgs,
|
| 1684 |
+
endpointDefinition,
|
| 1685 |
+
endpointName
|
| 1686 |
+
});
|
| 1687 |
+
const selectQuerySubstate = (state) => selectQueryEntry(state, serializedArgs) ?? defaultQuerySubState;
|
| 1688 |
+
return createSelector2(selectQuerySubstate, combiner);
|
| 1689 |
+
};
|
| 1690 |
+
}
|
| 1691 |
+
function buildQuerySelector(endpointName, endpointDefinition) {
|
| 1692 |
+
return buildAnyQuerySelector(endpointName, endpointDefinition, withRequestFlags);
|
| 1693 |
+
}
|
| 1694 |
+
function buildInfiniteQuerySelector(endpointName, endpointDefinition) {
|
| 1695 |
+
const {
|
| 1696 |
+
infiniteQueryOptions
|
| 1697 |
+
} = endpointDefinition;
|
| 1698 |
+
function withInfiniteQueryResultFlags(substate) {
|
| 1699 |
+
const stateWithRequestFlags = {
|
| 1700 |
+
...substate,
|
| 1701 |
+
...getRequestStatusFlags(substate.status)
|
| 1702 |
+
};
|
| 1703 |
+
const {
|
| 1704 |
+
isLoading,
|
| 1705 |
+
isError,
|
| 1706 |
+
direction
|
| 1707 |
+
} = stateWithRequestFlags;
|
| 1708 |
+
const isForward = direction === "forward";
|
| 1709 |
+
const isBackward = direction === "backward";
|
| 1710 |
+
return {
|
| 1711 |
+
...stateWithRequestFlags,
|
| 1712 |
+
hasNextPage: getHasNextPage(infiniteQueryOptions, stateWithRequestFlags.data, stateWithRequestFlags.originalArgs),
|
| 1713 |
+
hasPreviousPage: getHasPreviousPage(infiniteQueryOptions, stateWithRequestFlags.data, stateWithRequestFlags.originalArgs),
|
| 1714 |
+
isFetchingNextPage: isLoading && isForward,
|
| 1715 |
+
isFetchingPreviousPage: isLoading && isBackward,
|
| 1716 |
+
isFetchNextPageError: isError && isForward,
|
| 1717 |
+
isFetchPreviousPageError: isError && isBackward
|
| 1718 |
+
};
|
| 1719 |
+
}
|
| 1720 |
+
return buildAnyQuerySelector(endpointName, endpointDefinition, withInfiniteQueryResultFlags);
|
| 1721 |
+
}
|
| 1722 |
+
function buildMutationSelector() {
|
| 1723 |
+
return (id) => {
|
| 1724 |
+
let mutationId;
|
| 1725 |
+
if (typeof id === "object") {
|
| 1726 |
+
mutationId = getMutationCacheKey(id) ?? skipToken;
|
| 1727 |
+
} else {
|
| 1728 |
+
mutationId = id;
|
| 1729 |
+
}
|
| 1730 |
+
const selectMutationSubstate = (state) => selectApiState(state)?.mutations?.[mutationId] ?? defaultMutationSubState;
|
| 1731 |
+
const finalSelectMutationSubstate = mutationId === skipToken ? selectSkippedMutation : selectMutationSubstate;
|
| 1732 |
+
return createSelector2(finalSelectMutationSubstate, withRequestFlags);
|
| 1733 |
+
};
|
| 1734 |
+
}
|
| 1735 |
+
function selectInvalidatedBy(state, tags) {
|
| 1736 |
+
const apiState = state[reducerPath];
|
| 1737 |
+
const toInvalidate = /* @__PURE__ */ new Set();
|
| 1738 |
+
for (const tag of tags.filter(isNotNullish).map(expandTagDescription)) {
|
| 1739 |
+
const provided = apiState.provided.tags[tag.type];
|
| 1740 |
+
if (!provided) {
|
| 1741 |
+
continue;
|
| 1742 |
+
}
|
| 1743 |
+
let invalidateSubscriptions = (tag.id !== void 0 ? (
|
| 1744 |
+
// id given: invalidate all queries that provide this type & id
|
| 1745 |
+
provided[tag.id]
|
| 1746 |
+
) : (
|
| 1747 |
+
// no id: invalidate all queries that provide this type
|
| 1748 |
+
flatten(Object.values(provided))
|
| 1749 |
+
)) ?? [];
|
| 1750 |
+
for (const invalidate of invalidateSubscriptions) {
|
| 1751 |
+
toInvalidate.add(invalidate);
|
| 1752 |
+
}
|
| 1753 |
+
}
|
| 1754 |
+
return flatten(Array.from(toInvalidate.values()).map((queryCacheKey) => {
|
| 1755 |
+
const querySubState = apiState.queries[queryCacheKey];
|
| 1756 |
+
return querySubState ? [{
|
| 1757 |
+
queryCacheKey,
|
| 1758 |
+
endpointName: querySubState.endpointName,
|
| 1759 |
+
originalArgs: querySubState.originalArgs
|
| 1760 |
+
}] : [];
|
| 1761 |
+
}));
|
| 1762 |
+
}
|
| 1763 |
+
function selectCachedArgsForQuery(state, queryName) {
|
| 1764 |
+
return Object.values(selectQueries(state)).filter((entry) => entry?.endpointName === queryName && entry.status !== "uninitialized" /* uninitialized */).map((entry) => entry.originalArgs);
|
| 1765 |
+
}
|
| 1766 |
+
function getHasNextPage(options, data, queryArg) {
|
| 1767 |
+
if (!data) return false;
|
| 1768 |
+
return getNextPageParam(options, data, queryArg) != null;
|
| 1769 |
+
}
|
| 1770 |
+
function getHasPreviousPage(options, data, queryArg) {
|
| 1771 |
+
if (!data || !options.getPreviousPageParam) return false;
|
| 1772 |
+
return getPreviousPageParam(options, data, queryArg) != null;
|
| 1773 |
+
}
|
| 1774 |
+
}
|
| 1775 |
+
|
| 1776 |
+
// src/query/createApi.ts
|
| 1777 |
+
import { formatProdErrorMessage as _formatProdErrorMessage2, formatProdErrorMessage as _formatProdErrorMessage22, formatProdErrorMessage as _formatProdErrorMessage3 } from "@reduxjs/toolkit";
|
| 1778 |
+
|
| 1779 |
+
// src/query/defaultSerializeQueryArgs.ts
|
| 1780 |
+
var cache = WeakMap ? /* @__PURE__ */ new WeakMap() : void 0;
|
| 1781 |
+
var defaultSerializeQueryArgs = ({
|
| 1782 |
+
endpointName,
|
| 1783 |
+
queryArgs
|
| 1784 |
+
}) => {
|
| 1785 |
+
let serialized = "";
|
| 1786 |
+
const cached = cache?.get(queryArgs);
|
| 1787 |
+
if (typeof cached === "string") {
|
| 1788 |
+
serialized = cached;
|
| 1789 |
+
} else {
|
| 1790 |
+
const stringified = JSON.stringify(queryArgs, (key, value) => {
|
| 1791 |
+
value = typeof value === "bigint" ? {
|
| 1792 |
+
$bigint: value.toString()
|
| 1793 |
+
} : value;
|
| 1794 |
+
value = isPlainObject(value) ? Object.keys(value).sort().reduce((acc, key2) => {
|
| 1795 |
+
acc[key2] = value[key2];
|
| 1796 |
+
return acc;
|
| 1797 |
+
}, {}) : value;
|
| 1798 |
+
return value;
|
| 1799 |
+
});
|
| 1800 |
+
if (isPlainObject(queryArgs)) {
|
| 1801 |
+
cache?.set(queryArgs, stringified);
|
| 1802 |
+
}
|
| 1803 |
+
serialized = stringified;
|
| 1804 |
+
}
|
| 1805 |
+
return `${endpointName}(${serialized})`;
|
| 1806 |
+
};
|
| 1807 |
+
|
| 1808 |
+
// src/query/createApi.ts
|
| 1809 |
+
import { weakMapMemoize } from "reselect";
|
| 1810 |
+
function buildCreateApi(...modules) {
|
| 1811 |
+
return function baseCreateApi(options) {
|
| 1812 |
+
const extractRehydrationInfo = weakMapMemoize((action) => options.extractRehydrationInfo?.(action, {
|
| 1813 |
+
reducerPath: options.reducerPath ?? "api"
|
| 1814 |
+
}));
|
| 1815 |
+
const optionsWithDefaults = {
|
| 1816 |
+
reducerPath: "api",
|
| 1817 |
+
keepUnusedDataFor: 60,
|
| 1818 |
+
refetchOnMountOrArgChange: false,
|
| 1819 |
+
refetchOnFocus: false,
|
| 1820 |
+
refetchOnReconnect: false,
|
| 1821 |
+
invalidationBehavior: "delayed",
|
| 1822 |
+
...options,
|
| 1823 |
+
extractRehydrationInfo,
|
| 1824 |
+
serializeQueryArgs(queryArgsApi) {
|
| 1825 |
+
let finalSerializeQueryArgs = defaultSerializeQueryArgs;
|
| 1826 |
+
if ("serializeQueryArgs" in queryArgsApi.endpointDefinition) {
|
| 1827 |
+
const endpointSQA = queryArgsApi.endpointDefinition.serializeQueryArgs;
|
| 1828 |
+
finalSerializeQueryArgs = (queryArgsApi2) => {
|
| 1829 |
+
const initialResult = endpointSQA(queryArgsApi2);
|
| 1830 |
+
if (typeof initialResult === "string") {
|
| 1831 |
+
return initialResult;
|
| 1832 |
+
} else {
|
| 1833 |
+
return defaultSerializeQueryArgs({
|
| 1834 |
+
...queryArgsApi2,
|
| 1835 |
+
queryArgs: initialResult
|
| 1836 |
+
});
|
| 1837 |
+
}
|
| 1838 |
+
};
|
| 1839 |
+
} else if (options.serializeQueryArgs) {
|
| 1840 |
+
finalSerializeQueryArgs = options.serializeQueryArgs;
|
| 1841 |
+
}
|
| 1842 |
+
return finalSerializeQueryArgs(queryArgsApi);
|
| 1843 |
+
},
|
| 1844 |
+
tagTypes: [...options.tagTypes || []]
|
| 1845 |
+
};
|
| 1846 |
+
const context = {
|
| 1847 |
+
endpointDefinitions: {},
|
| 1848 |
+
batch(fn) {
|
| 1849 |
+
fn();
|
| 1850 |
+
},
|
| 1851 |
+
apiUid: nanoid(),
|
| 1852 |
+
extractRehydrationInfo,
|
| 1853 |
+
hasRehydrationInfo: weakMapMemoize((action) => extractRehydrationInfo(action) != null)
|
| 1854 |
+
};
|
| 1855 |
+
const api = {
|
| 1856 |
+
injectEndpoints,
|
| 1857 |
+
enhanceEndpoints({
|
| 1858 |
+
addTagTypes,
|
| 1859 |
+
endpoints
|
| 1860 |
+
}) {
|
| 1861 |
+
if (addTagTypes) {
|
| 1862 |
+
for (const eT of addTagTypes) {
|
| 1863 |
+
if (!optionsWithDefaults.tagTypes.includes(eT)) {
|
| 1864 |
+
;
|
| 1865 |
+
optionsWithDefaults.tagTypes.push(eT);
|
| 1866 |
+
}
|
| 1867 |
+
}
|
| 1868 |
+
}
|
| 1869 |
+
if (endpoints) {
|
| 1870 |
+
for (const [endpointName, partialDefinition] of Object.entries(endpoints)) {
|
| 1871 |
+
if (typeof partialDefinition === "function") {
|
| 1872 |
+
partialDefinition(context.endpointDefinitions[endpointName]);
|
| 1873 |
+
} else {
|
| 1874 |
+
Object.assign(context.endpointDefinitions[endpointName] || {}, partialDefinition);
|
| 1875 |
+
}
|
| 1876 |
+
}
|
| 1877 |
+
}
|
| 1878 |
+
return api;
|
| 1879 |
+
}
|
| 1880 |
+
};
|
| 1881 |
+
const initializedModules = modules.map((m) => m.init(api, optionsWithDefaults, context));
|
| 1882 |
+
function injectEndpoints(inject) {
|
| 1883 |
+
const evaluatedEndpoints = inject.endpoints({
|
| 1884 |
+
query: (x) => ({
|
| 1885 |
+
...x,
|
| 1886 |
+
type: "query" /* query */
|
| 1887 |
+
}),
|
| 1888 |
+
mutation: (x) => ({
|
| 1889 |
+
...x,
|
| 1890 |
+
type: "mutation" /* mutation */
|
| 1891 |
+
}),
|
| 1892 |
+
infiniteQuery: (x) => ({
|
| 1893 |
+
...x,
|
| 1894 |
+
type: "infinitequery" /* infinitequery */
|
| 1895 |
+
})
|
| 1896 |
+
});
|
| 1897 |
+
for (const [endpointName, definition] of Object.entries(evaluatedEndpoints)) {
|
| 1898 |
+
if (inject.overrideExisting !== true && endpointName in context.endpointDefinitions) {
|
| 1899 |
+
if (inject.overrideExisting === "throw") {
|
| 1900 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage2(39) : `called \`injectEndpoints\` to override already-existing endpointName ${endpointName} without specifying \`overrideExisting: true\``);
|
| 1901 |
+
} else if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
| 1902 |
+
console.error(`called \`injectEndpoints\` to override already-existing endpointName ${endpointName} without specifying \`overrideExisting: true\``);
|
| 1903 |
+
}
|
| 1904 |
+
continue;
|
| 1905 |
+
}
|
| 1906 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
| 1907 |
+
if (isInfiniteQueryDefinition(definition)) {
|
| 1908 |
+
const {
|
| 1909 |
+
infiniteQueryOptions
|
| 1910 |
+
} = definition;
|
| 1911 |
+
const {
|
| 1912 |
+
maxPages,
|
| 1913 |
+
getPreviousPageParam: getPreviousPageParam2
|
| 1914 |
+
} = infiniteQueryOptions;
|
| 1915 |
+
if (typeof maxPages === "number") {
|
| 1916 |
+
if (maxPages < 1) {
|
| 1917 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage22(40) : `maxPages for endpoint '${endpointName}' must be a number greater than 0`);
|
| 1918 |
+
}
|
| 1919 |
+
if (typeof getPreviousPageParam2 !== "function") {
|
| 1920 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage3(41) : `getPreviousPageParam for endpoint '${endpointName}' must be a function if maxPages is used`);
|
| 1921 |
+
}
|
| 1922 |
+
}
|
| 1923 |
+
}
|
| 1924 |
+
}
|
| 1925 |
+
context.endpointDefinitions[endpointName] = definition;
|
| 1926 |
+
for (const m of initializedModules) {
|
| 1927 |
+
m.injectEndpoint(endpointName, definition);
|
| 1928 |
+
}
|
| 1929 |
+
}
|
| 1930 |
+
return api;
|
| 1931 |
+
}
|
| 1932 |
+
return api.injectEndpoints({
|
| 1933 |
+
endpoints: options.endpoints
|
| 1934 |
+
});
|
| 1935 |
+
};
|
| 1936 |
+
}
|
| 1937 |
+
|
| 1938 |
+
// src/query/fakeBaseQuery.ts
|
| 1939 |
+
import { formatProdErrorMessage as _formatProdErrorMessage4 } from "@reduxjs/toolkit";
|
| 1940 |
+
var _NEVER = /* @__PURE__ */ Symbol();
|
| 1941 |
+
function fakeBaseQuery() {
|
| 1942 |
+
return function() {
|
| 1943 |
+
throw new Error(process.env.NODE_ENV === "production" ? _formatProdErrorMessage4(33) : "When using `fakeBaseQuery`, all queries & mutations must use the `queryFn` definition syntax.");
|
| 1944 |
+
};
|
| 1945 |
+
}
|
| 1946 |
+
|
| 1947 |
+
// src/query/core/module.ts
|
| 1948 |
+
import { enablePatches } from "immer";
|
| 1949 |
+
|
| 1950 |
+
// src/query/tsHelpers.ts
|
| 1951 |
+
function assertCast(v) {
|
| 1952 |
+
}
|
| 1953 |
+
function safeAssign(target, ...args) {
|
| 1954 |
+
return Object.assign(target, ...args);
|
| 1955 |
+
}
|
| 1956 |
+
|
| 1957 |
+
// src/query/core/buildMiddleware/batchActions.ts
|
| 1958 |
+
import { produceWithPatches as produceWithPatches2 } from "immer";
|
| 1959 |
+
var buildBatchedActionsHandler = ({
|
| 1960 |
+
api,
|
| 1961 |
+
queryThunk,
|
| 1962 |
+
internalState
|
| 1963 |
+
}) => {
|
| 1964 |
+
const subscriptionsPrefix = `${api.reducerPath}/subscriptions`;
|
| 1965 |
+
let previousSubscriptions = null;
|
| 1966 |
+
let updateSyncTimer = null;
|
| 1967 |
+
const {
|
| 1968 |
+
updateSubscriptionOptions,
|
| 1969 |
+
unsubscribeQueryResult
|
| 1970 |
+
} = api.internalActions;
|
| 1971 |
+
const actuallyMutateSubscriptions = (mutableState, action) => {
|
| 1972 |
+
if (updateSubscriptionOptions.match(action)) {
|
| 1973 |
+
const {
|
| 1974 |
+
queryCacheKey,
|
| 1975 |
+
requestId,
|
| 1976 |
+
options
|
| 1977 |
+
} = action.payload;
|
| 1978 |
+
if (mutableState?.[queryCacheKey]?.[requestId]) {
|
| 1979 |
+
mutableState[queryCacheKey][requestId] = options;
|
| 1980 |
+
}
|
| 1981 |
+
return true;
|
| 1982 |
+
}
|
| 1983 |
+
if (unsubscribeQueryResult.match(action)) {
|
| 1984 |
+
const {
|
| 1985 |
+
queryCacheKey,
|
| 1986 |
+
requestId
|
| 1987 |
+
} = action.payload;
|
| 1988 |
+
if (mutableState[queryCacheKey]) {
|
| 1989 |
+
delete mutableState[queryCacheKey][requestId];
|
| 1990 |
+
}
|
| 1991 |
+
return true;
|
| 1992 |
+
}
|
| 1993 |
+
if (api.internalActions.removeQueryResult.match(action)) {
|
| 1994 |
+
delete mutableState[action.payload.queryCacheKey];
|
| 1995 |
+
return true;
|
| 1996 |
+
}
|
| 1997 |
+
if (queryThunk.pending.match(action)) {
|
| 1998 |
+
const {
|
| 1999 |
+
meta: {
|
| 2000 |
+
arg,
|
| 2001 |
+
requestId
|
| 2002 |
+
}
|
| 2003 |
+
} = action;
|
| 2004 |
+
const substate = mutableState[arg.queryCacheKey] ??= {};
|
| 2005 |
+
substate[`${requestId}_running`] = {};
|
| 2006 |
+
if (arg.subscribe) {
|
| 2007 |
+
substate[requestId] = arg.subscriptionOptions ?? substate[requestId] ?? {};
|
| 2008 |
+
}
|
| 2009 |
+
return true;
|
| 2010 |
+
}
|
| 2011 |
+
let mutated = false;
|
| 2012 |
+
if (queryThunk.fulfilled.match(action) || queryThunk.rejected.match(action)) {
|
| 2013 |
+
const state = mutableState[action.meta.arg.queryCacheKey] || {};
|
| 2014 |
+
const key = `${action.meta.requestId}_running`;
|
| 2015 |
+
mutated ||= !!state[key];
|
| 2016 |
+
delete state[key];
|
| 2017 |
+
}
|
| 2018 |
+
if (queryThunk.rejected.match(action)) {
|
| 2019 |
+
const {
|
| 2020 |
+
meta: {
|
| 2021 |
+
condition,
|
| 2022 |
+
arg,
|
| 2023 |
+
requestId
|
| 2024 |
+
}
|
| 2025 |
+
} = action;
|
| 2026 |
+
if (condition && arg.subscribe) {
|
| 2027 |
+
const substate = mutableState[arg.queryCacheKey] ??= {};
|
| 2028 |
+
substate[requestId] = arg.subscriptionOptions ?? substate[requestId] ?? {};
|
| 2029 |
+
mutated = true;
|
| 2030 |
+
}
|
| 2031 |
+
}
|
| 2032 |
+
return mutated;
|
| 2033 |
+
};
|
| 2034 |
+
const getSubscriptions = () => internalState.currentSubscriptions;
|
| 2035 |
+
const getSubscriptionCount = (queryCacheKey) => {
|
| 2036 |
+
const subscriptions = getSubscriptions();
|
| 2037 |
+
const subscriptionsForQueryArg = subscriptions[queryCacheKey] ?? {};
|
| 2038 |
+
return countObjectKeys(subscriptionsForQueryArg);
|
| 2039 |
+
};
|
| 2040 |
+
const isRequestSubscribed = (queryCacheKey, requestId) => {
|
| 2041 |
+
const subscriptions = getSubscriptions();
|
| 2042 |
+
return !!subscriptions?.[queryCacheKey]?.[requestId];
|
| 2043 |
+
};
|
| 2044 |
+
const subscriptionSelectors = {
|
| 2045 |
+
getSubscriptions,
|
| 2046 |
+
getSubscriptionCount,
|
| 2047 |
+
isRequestSubscribed
|
| 2048 |
+
};
|
| 2049 |
+
return (action, mwApi) => {
|
| 2050 |
+
if (!previousSubscriptions) {
|
| 2051 |
+
previousSubscriptions = JSON.parse(JSON.stringify(internalState.currentSubscriptions));
|
| 2052 |
+
}
|
| 2053 |
+
if (api.util.resetApiState.match(action)) {
|
| 2054 |
+
previousSubscriptions = internalState.currentSubscriptions = {};
|
| 2055 |
+
updateSyncTimer = null;
|
| 2056 |
+
return [true, false];
|
| 2057 |
+
}
|
| 2058 |
+
if (api.internalActions.internal_getRTKQSubscriptions.match(action)) {
|
| 2059 |
+
return [false, subscriptionSelectors];
|
| 2060 |
+
}
|
| 2061 |
+
const didMutate = actuallyMutateSubscriptions(internalState.currentSubscriptions, action);
|
| 2062 |
+
let actionShouldContinue = true;
|
| 2063 |
+
if (didMutate) {
|
| 2064 |
+
if (!updateSyncTimer) {
|
| 2065 |
+
updateSyncTimer = setTimeout(() => {
|
| 2066 |
+
const newSubscriptions = JSON.parse(JSON.stringify(internalState.currentSubscriptions));
|
| 2067 |
+
const [, patches] = produceWithPatches2(previousSubscriptions, () => newSubscriptions);
|
| 2068 |
+
mwApi.next(api.internalActions.subscriptionsUpdated(patches));
|
| 2069 |
+
previousSubscriptions = newSubscriptions;
|
| 2070 |
+
updateSyncTimer = null;
|
| 2071 |
+
}, 500);
|
| 2072 |
+
}
|
| 2073 |
+
const isSubscriptionSliceAction = typeof action.type == "string" && !!action.type.startsWith(subscriptionsPrefix);
|
| 2074 |
+
const isAdditionalSubscriptionAction = queryThunk.rejected.match(action) && action.meta.condition && !!action.meta.arg.subscribe;
|
| 2075 |
+
actionShouldContinue = !isSubscriptionSliceAction && !isAdditionalSubscriptionAction;
|
| 2076 |
+
}
|
| 2077 |
+
return [actionShouldContinue, false];
|
| 2078 |
+
};
|
| 2079 |
+
};
|
| 2080 |
+
|
| 2081 |
+
// src/query/core/buildMiddleware/cacheCollection.ts
|
| 2082 |
+
function isObjectEmpty(obj) {
|
| 2083 |
+
for (const k in obj) {
|
| 2084 |
+
return false;
|
| 2085 |
+
}
|
| 2086 |
+
return true;
|
| 2087 |
+
}
|
| 2088 |
+
var THIRTY_TWO_BIT_MAX_TIMER_SECONDS = 2147483647 / 1e3 - 1;
|
| 2089 |
+
var buildCacheCollectionHandler = ({
|
| 2090 |
+
reducerPath,
|
| 2091 |
+
api,
|
| 2092 |
+
queryThunk,
|
| 2093 |
+
context,
|
| 2094 |
+
internalState,
|
| 2095 |
+
selectors: {
|
| 2096 |
+
selectQueryEntry,
|
| 2097 |
+
selectConfig
|
| 2098 |
+
}
|
| 2099 |
+
}) => {
|
| 2100 |
+
const {
|
| 2101 |
+
removeQueryResult,
|
| 2102 |
+
unsubscribeQueryResult,
|
| 2103 |
+
cacheEntriesUpserted
|
| 2104 |
+
} = api.internalActions;
|
| 2105 |
+
const canTriggerUnsubscribe = isAnyOf(unsubscribeQueryResult.match, queryThunk.fulfilled, queryThunk.rejected, cacheEntriesUpserted.match);
|
| 2106 |
+
function anySubscriptionsRemainingForKey(queryCacheKey) {
|
| 2107 |
+
const subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
| 2108 |
+
return !!subscriptions && !isObjectEmpty(subscriptions);
|
| 2109 |
+
}
|
| 2110 |
+
const currentRemovalTimeouts = {};
|
| 2111 |
+
const handler = (action, mwApi, internalState2) => {
|
| 2112 |
+
const state = mwApi.getState();
|
| 2113 |
+
const config = selectConfig(state);
|
| 2114 |
+
if (canTriggerUnsubscribe(action)) {
|
| 2115 |
+
let queryCacheKeys;
|
| 2116 |
+
if (cacheEntriesUpserted.match(action)) {
|
| 2117 |
+
queryCacheKeys = action.payload.map((entry) => entry.queryDescription.queryCacheKey);
|
| 2118 |
+
} else {
|
| 2119 |
+
const {
|
| 2120 |
+
queryCacheKey
|
| 2121 |
+
} = unsubscribeQueryResult.match(action) ? action.payload : action.meta.arg;
|
| 2122 |
+
queryCacheKeys = [queryCacheKey];
|
| 2123 |
+
}
|
| 2124 |
+
handleUnsubscribeMany(queryCacheKeys, mwApi, config);
|
| 2125 |
+
}
|
| 2126 |
+
if (api.util.resetApiState.match(action)) {
|
| 2127 |
+
for (const [key, timeout] of Object.entries(currentRemovalTimeouts)) {
|
| 2128 |
+
if (timeout) clearTimeout(timeout);
|
| 2129 |
+
delete currentRemovalTimeouts[key];
|
| 2130 |
+
}
|
| 2131 |
+
}
|
| 2132 |
+
if (context.hasRehydrationInfo(action)) {
|
| 2133 |
+
const {
|
| 2134 |
+
queries
|
| 2135 |
+
} = context.extractRehydrationInfo(action);
|
| 2136 |
+
handleUnsubscribeMany(Object.keys(queries), mwApi, config);
|
| 2137 |
+
}
|
| 2138 |
+
};
|
| 2139 |
+
function handleUnsubscribeMany(cacheKeys, api2, config) {
|
| 2140 |
+
const state = api2.getState();
|
| 2141 |
+
for (const queryCacheKey of cacheKeys) {
|
| 2142 |
+
const entry = selectQueryEntry(state, queryCacheKey);
|
| 2143 |
+
handleUnsubscribe(queryCacheKey, entry?.endpointName, api2, config);
|
| 2144 |
+
}
|
| 2145 |
+
}
|
| 2146 |
+
function handleUnsubscribe(queryCacheKey, endpointName, api2, config) {
|
| 2147 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 2148 |
+
const keepUnusedDataFor = endpointDefinition?.keepUnusedDataFor ?? config.keepUnusedDataFor;
|
| 2149 |
+
if (keepUnusedDataFor === Infinity) {
|
| 2150 |
+
return;
|
| 2151 |
+
}
|
| 2152 |
+
const finalKeepUnusedDataFor = Math.max(0, Math.min(keepUnusedDataFor, THIRTY_TWO_BIT_MAX_TIMER_SECONDS));
|
| 2153 |
+
if (!anySubscriptionsRemainingForKey(queryCacheKey)) {
|
| 2154 |
+
const currentTimeout = currentRemovalTimeouts[queryCacheKey];
|
| 2155 |
+
if (currentTimeout) {
|
| 2156 |
+
clearTimeout(currentTimeout);
|
| 2157 |
+
}
|
| 2158 |
+
currentRemovalTimeouts[queryCacheKey] = setTimeout(() => {
|
| 2159 |
+
if (!anySubscriptionsRemainingForKey(queryCacheKey)) {
|
| 2160 |
+
api2.dispatch(removeQueryResult({
|
| 2161 |
+
queryCacheKey
|
| 2162 |
+
}));
|
| 2163 |
+
}
|
| 2164 |
+
delete currentRemovalTimeouts[queryCacheKey];
|
| 2165 |
+
}, finalKeepUnusedDataFor * 1e3);
|
| 2166 |
+
}
|
| 2167 |
+
}
|
| 2168 |
+
return handler;
|
| 2169 |
+
};
|
| 2170 |
+
|
| 2171 |
+
// src/query/core/buildMiddleware/cacheLifecycle.ts
|
| 2172 |
+
var neverResolvedError = new Error("Promise never resolved before cacheEntryRemoved.");
|
| 2173 |
+
var buildCacheLifecycleHandler = ({
|
| 2174 |
+
api,
|
| 2175 |
+
reducerPath,
|
| 2176 |
+
context,
|
| 2177 |
+
queryThunk,
|
| 2178 |
+
mutationThunk,
|
| 2179 |
+
internalState,
|
| 2180 |
+
selectors: {
|
| 2181 |
+
selectQueryEntry,
|
| 2182 |
+
selectApiState
|
| 2183 |
+
}
|
| 2184 |
+
}) => {
|
| 2185 |
+
const isQueryThunk = isAsyncThunkAction(queryThunk);
|
| 2186 |
+
const isMutationThunk = isAsyncThunkAction(mutationThunk);
|
| 2187 |
+
const isFulfilledThunk = isFulfilled(queryThunk, mutationThunk);
|
| 2188 |
+
const lifecycleMap = {};
|
| 2189 |
+
function resolveLifecycleEntry(cacheKey, data, meta) {
|
| 2190 |
+
const lifecycle = lifecycleMap[cacheKey];
|
| 2191 |
+
if (lifecycle?.valueResolved) {
|
| 2192 |
+
lifecycle.valueResolved({
|
| 2193 |
+
data,
|
| 2194 |
+
meta
|
| 2195 |
+
});
|
| 2196 |
+
delete lifecycle.valueResolved;
|
| 2197 |
+
}
|
| 2198 |
+
}
|
| 2199 |
+
function removeLifecycleEntry(cacheKey) {
|
| 2200 |
+
const lifecycle = lifecycleMap[cacheKey];
|
| 2201 |
+
if (lifecycle) {
|
| 2202 |
+
delete lifecycleMap[cacheKey];
|
| 2203 |
+
lifecycle.cacheEntryRemoved();
|
| 2204 |
+
}
|
| 2205 |
+
}
|
| 2206 |
+
const handler = (action, mwApi, stateBefore) => {
|
| 2207 |
+
const cacheKey = getCacheKey(action);
|
| 2208 |
+
function checkForNewCacheKey(endpointName, cacheKey2, requestId, originalArgs) {
|
| 2209 |
+
const oldEntry = selectQueryEntry(stateBefore, cacheKey2);
|
| 2210 |
+
const newEntry = selectQueryEntry(mwApi.getState(), cacheKey2);
|
| 2211 |
+
if (!oldEntry && newEntry) {
|
| 2212 |
+
handleNewKey(endpointName, originalArgs, cacheKey2, mwApi, requestId);
|
| 2213 |
+
}
|
| 2214 |
+
}
|
| 2215 |
+
if (queryThunk.pending.match(action)) {
|
| 2216 |
+
checkForNewCacheKey(action.meta.arg.endpointName, cacheKey, action.meta.requestId, action.meta.arg.originalArgs);
|
| 2217 |
+
} else if (api.internalActions.cacheEntriesUpserted.match(action)) {
|
| 2218 |
+
for (const {
|
| 2219 |
+
queryDescription,
|
| 2220 |
+
value
|
| 2221 |
+
} of action.payload) {
|
| 2222 |
+
const {
|
| 2223 |
+
endpointName,
|
| 2224 |
+
originalArgs,
|
| 2225 |
+
queryCacheKey
|
| 2226 |
+
} = queryDescription;
|
| 2227 |
+
checkForNewCacheKey(endpointName, queryCacheKey, action.meta.requestId, originalArgs);
|
| 2228 |
+
resolveLifecycleEntry(queryCacheKey, value, {});
|
| 2229 |
+
}
|
| 2230 |
+
} else if (mutationThunk.pending.match(action)) {
|
| 2231 |
+
const state = mwApi.getState()[reducerPath].mutations[cacheKey];
|
| 2232 |
+
if (state) {
|
| 2233 |
+
handleNewKey(action.meta.arg.endpointName, action.meta.arg.originalArgs, cacheKey, mwApi, action.meta.requestId);
|
| 2234 |
+
}
|
| 2235 |
+
} else if (isFulfilledThunk(action)) {
|
| 2236 |
+
resolveLifecycleEntry(cacheKey, action.payload, action.meta.baseQueryMeta);
|
| 2237 |
+
} else if (api.internalActions.removeQueryResult.match(action) || api.internalActions.removeMutationResult.match(action)) {
|
| 2238 |
+
removeLifecycleEntry(cacheKey);
|
| 2239 |
+
} else if (api.util.resetApiState.match(action)) {
|
| 2240 |
+
for (const cacheKey2 of Object.keys(lifecycleMap)) {
|
| 2241 |
+
removeLifecycleEntry(cacheKey2);
|
| 2242 |
+
}
|
| 2243 |
+
}
|
| 2244 |
+
};
|
| 2245 |
+
function getCacheKey(action) {
|
| 2246 |
+
if (isQueryThunk(action)) return action.meta.arg.queryCacheKey;
|
| 2247 |
+
if (isMutationThunk(action)) {
|
| 2248 |
+
return action.meta.arg.fixedCacheKey ?? action.meta.requestId;
|
| 2249 |
+
}
|
| 2250 |
+
if (api.internalActions.removeQueryResult.match(action)) return action.payload.queryCacheKey;
|
| 2251 |
+
if (api.internalActions.removeMutationResult.match(action)) return getMutationCacheKey(action.payload);
|
| 2252 |
+
return "";
|
| 2253 |
+
}
|
| 2254 |
+
function handleNewKey(endpointName, originalArgs, queryCacheKey, mwApi, requestId) {
|
| 2255 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 2256 |
+
const onCacheEntryAdded = endpointDefinition?.onCacheEntryAdded;
|
| 2257 |
+
if (!onCacheEntryAdded) return;
|
| 2258 |
+
const lifecycle = {};
|
| 2259 |
+
const cacheEntryRemoved = new Promise((resolve) => {
|
| 2260 |
+
lifecycle.cacheEntryRemoved = resolve;
|
| 2261 |
+
});
|
| 2262 |
+
const cacheDataLoaded = Promise.race([new Promise((resolve) => {
|
| 2263 |
+
lifecycle.valueResolved = resolve;
|
| 2264 |
+
}), cacheEntryRemoved.then(() => {
|
| 2265 |
+
throw neverResolvedError;
|
| 2266 |
+
})]);
|
| 2267 |
+
cacheDataLoaded.catch(() => {
|
| 2268 |
+
});
|
| 2269 |
+
lifecycleMap[queryCacheKey] = lifecycle;
|
| 2270 |
+
const selector = api.endpoints[endpointName].select(isAnyQueryDefinition(endpointDefinition) ? originalArgs : queryCacheKey);
|
| 2271 |
+
const extra = mwApi.dispatch((_, __, extra2) => extra2);
|
| 2272 |
+
const lifecycleApi = {
|
| 2273 |
+
...mwApi,
|
| 2274 |
+
getCacheEntry: () => selector(mwApi.getState()),
|
| 2275 |
+
requestId,
|
| 2276 |
+
extra,
|
| 2277 |
+
updateCachedData: isAnyQueryDefinition(endpointDefinition) ? (updateRecipe) => mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)) : void 0,
|
| 2278 |
+
cacheDataLoaded,
|
| 2279 |
+
cacheEntryRemoved
|
| 2280 |
+
};
|
| 2281 |
+
const runningHandler = onCacheEntryAdded(originalArgs, lifecycleApi);
|
| 2282 |
+
Promise.resolve(runningHandler).catch((e) => {
|
| 2283 |
+
if (e === neverResolvedError) return;
|
| 2284 |
+
throw e;
|
| 2285 |
+
});
|
| 2286 |
+
}
|
| 2287 |
+
return handler;
|
| 2288 |
+
};
|
| 2289 |
+
|
| 2290 |
+
// src/query/core/buildMiddleware/devMiddleware.ts
|
| 2291 |
+
var buildDevCheckHandler = ({
|
| 2292 |
+
api,
|
| 2293 |
+
context: {
|
| 2294 |
+
apiUid
|
| 2295 |
+
},
|
| 2296 |
+
reducerPath
|
| 2297 |
+
}) => {
|
| 2298 |
+
return (action, mwApi) => {
|
| 2299 |
+
if (api.util.resetApiState.match(action)) {
|
| 2300 |
+
mwApi.dispatch(api.internalActions.middlewareRegistered(apiUid));
|
| 2301 |
+
}
|
| 2302 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
| 2303 |
+
if (api.internalActions.middlewareRegistered.match(action) && action.payload === apiUid && mwApi.getState()[reducerPath]?.config?.middlewareRegistered === "conflict") {
|
| 2304 |
+
console.warn(`There is a mismatch between slice and middleware for the reducerPath "${reducerPath}".
|
| 2305 |
+
You can only have one api per reducer path, this will lead to crashes in various situations!${reducerPath === "api" ? `
|
| 2306 |
+
If you have multiple apis, you *have* to specify the reducerPath option when using createApi!` : ""}`);
|
| 2307 |
+
}
|
| 2308 |
+
}
|
| 2309 |
+
};
|
| 2310 |
+
};
|
| 2311 |
+
|
| 2312 |
+
// src/query/core/buildMiddleware/invalidationByTags.ts
|
| 2313 |
+
var buildInvalidationByTagsHandler = ({
|
| 2314 |
+
reducerPath,
|
| 2315 |
+
context,
|
| 2316 |
+
context: {
|
| 2317 |
+
endpointDefinitions
|
| 2318 |
+
},
|
| 2319 |
+
mutationThunk,
|
| 2320 |
+
queryThunk,
|
| 2321 |
+
api,
|
| 2322 |
+
assertTagType,
|
| 2323 |
+
refetchQuery,
|
| 2324 |
+
internalState
|
| 2325 |
+
}) => {
|
| 2326 |
+
const {
|
| 2327 |
+
removeQueryResult
|
| 2328 |
+
} = api.internalActions;
|
| 2329 |
+
const isThunkActionWithTags = isAnyOf(isFulfilled(mutationThunk), isRejectedWithValue(mutationThunk));
|
| 2330 |
+
const isQueryEnd = isAnyOf(isFulfilled(mutationThunk, queryThunk), isRejected(mutationThunk, queryThunk));
|
| 2331 |
+
let pendingTagInvalidations = [];
|
| 2332 |
+
const handler = (action, mwApi) => {
|
| 2333 |
+
if (isThunkActionWithTags(action)) {
|
| 2334 |
+
invalidateTags(calculateProvidedByThunk(action, "invalidatesTags", endpointDefinitions, assertTagType), mwApi);
|
| 2335 |
+
} else if (isQueryEnd(action)) {
|
| 2336 |
+
invalidateTags([], mwApi);
|
| 2337 |
+
} else if (api.util.invalidateTags.match(action)) {
|
| 2338 |
+
invalidateTags(calculateProvidedBy(action.payload, void 0, void 0, void 0, void 0, assertTagType), mwApi);
|
| 2339 |
+
}
|
| 2340 |
+
};
|
| 2341 |
+
function hasPendingRequests(state) {
|
| 2342 |
+
const {
|
| 2343 |
+
queries,
|
| 2344 |
+
mutations
|
| 2345 |
+
} = state;
|
| 2346 |
+
for (const cacheRecord of [queries, mutations]) {
|
| 2347 |
+
for (const key in cacheRecord) {
|
| 2348 |
+
if (cacheRecord[key]?.status === "pending" /* pending */) return true;
|
| 2349 |
+
}
|
| 2350 |
+
}
|
| 2351 |
+
return false;
|
| 2352 |
+
}
|
| 2353 |
+
function invalidateTags(newTags, mwApi) {
|
| 2354 |
+
const rootState = mwApi.getState();
|
| 2355 |
+
const state = rootState[reducerPath];
|
| 2356 |
+
pendingTagInvalidations.push(...newTags);
|
| 2357 |
+
if (state.config.invalidationBehavior === "delayed" && hasPendingRequests(state)) {
|
| 2358 |
+
return;
|
| 2359 |
+
}
|
| 2360 |
+
const tags = pendingTagInvalidations;
|
| 2361 |
+
pendingTagInvalidations = [];
|
| 2362 |
+
if (tags.length === 0) return;
|
| 2363 |
+
const toInvalidate = api.util.selectInvalidatedBy(rootState, tags);
|
| 2364 |
+
context.batch(() => {
|
| 2365 |
+
const valuesArray = Array.from(toInvalidate.values());
|
| 2366 |
+
for (const {
|
| 2367 |
+
queryCacheKey
|
| 2368 |
+
} of valuesArray) {
|
| 2369 |
+
const querySubState = state.queries[queryCacheKey];
|
| 2370 |
+
const subscriptionSubState = internalState.currentSubscriptions[queryCacheKey] ?? {};
|
| 2371 |
+
if (querySubState) {
|
| 2372 |
+
if (countObjectKeys(subscriptionSubState) === 0) {
|
| 2373 |
+
mwApi.dispatch(removeQueryResult({
|
| 2374 |
+
queryCacheKey
|
| 2375 |
+
}));
|
| 2376 |
+
} else if (querySubState.status !== "uninitialized" /* uninitialized */) {
|
| 2377 |
+
mwApi.dispatch(refetchQuery(querySubState));
|
| 2378 |
+
}
|
| 2379 |
+
}
|
| 2380 |
+
}
|
| 2381 |
+
});
|
| 2382 |
+
}
|
| 2383 |
+
return handler;
|
| 2384 |
+
};
|
| 2385 |
+
|
| 2386 |
+
// src/query/core/buildMiddleware/polling.ts
|
| 2387 |
+
var buildPollingHandler = ({
|
| 2388 |
+
reducerPath,
|
| 2389 |
+
queryThunk,
|
| 2390 |
+
api,
|
| 2391 |
+
refetchQuery,
|
| 2392 |
+
internalState
|
| 2393 |
+
}) => {
|
| 2394 |
+
const currentPolls = {};
|
| 2395 |
+
const handler = (action, mwApi) => {
|
| 2396 |
+
if (api.internalActions.updateSubscriptionOptions.match(action) || api.internalActions.unsubscribeQueryResult.match(action)) {
|
| 2397 |
+
updatePollingInterval(action.payload, mwApi);
|
| 2398 |
+
}
|
| 2399 |
+
if (queryThunk.pending.match(action) || queryThunk.rejected.match(action) && action.meta.condition) {
|
| 2400 |
+
updatePollingInterval(action.meta.arg, mwApi);
|
| 2401 |
+
}
|
| 2402 |
+
if (queryThunk.fulfilled.match(action) || queryThunk.rejected.match(action) && !action.meta.condition) {
|
| 2403 |
+
startNextPoll(action.meta.arg, mwApi);
|
| 2404 |
+
}
|
| 2405 |
+
if (api.util.resetApiState.match(action)) {
|
| 2406 |
+
clearPolls();
|
| 2407 |
+
}
|
| 2408 |
+
};
|
| 2409 |
+
function getCacheEntrySubscriptions(queryCacheKey, api2) {
|
| 2410 |
+
const state = api2.getState()[reducerPath];
|
| 2411 |
+
const querySubState = state.queries[queryCacheKey];
|
| 2412 |
+
const subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
| 2413 |
+
if (!querySubState || querySubState.status === "uninitialized" /* uninitialized */) return;
|
| 2414 |
+
return subscriptions;
|
| 2415 |
+
}
|
| 2416 |
+
function startNextPoll({
|
| 2417 |
+
queryCacheKey
|
| 2418 |
+
}, api2) {
|
| 2419 |
+
const state = api2.getState()[reducerPath];
|
| 2420 |
+
const querySubState = state.queries[queryCacheKey];
|
| 2421 |
+
const subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
| 2422 |
+
if (!querySubState || querySubState.status === "uninitialized" /* uninitialized */) return;
|
| 2423 |
+
const {
|
| 2424 |
+
lowestPollingInterval,
|
| 2425 |
+
skipPollingIfUnfocused
|
| 2426 |
+
} = findLowestPollingInterval(subscriptions);
|
| 2427 |
+
if (!Number.isFinite(lowestPollingInterval)) return;
|
| 2428 |
+
const currentPoll = currentPolls[queryCacheKey];
|
| 2429 |
+
if (currentPoll?.timeout) {
|
| 2430 |
+
clearTimeout(currentPoll.timeout);
|
| 2431 |
+
currentPoll.timeout = void 0;
|
| 2432 |
+
}
|
| 2433 |
+
const nextPollTimestamp = Date.now() + lowestPollingInterval;
|
| 2434 |
+
currentPolls[queryCacheKey] = {
|
| 2435 |
+
nextPollTimestamp,
|
| 2436 |
+
pollingInterval: lowestPollingInterval,
|
| 2437 |
+
timeout: setTimeout(() => {
|
| 2438 |
+
if (state.config.focused || !skipPollingIfUnfocused) {
|
| 2439 |
+
api2.dispatch(refetchQuery(querySubState));
|
| 2440 |
+
}
|
| 2441 |
+
startNextPoll({
|
| 2442 |
+
queryCacheKey
|
| 2443 |
+
}, api2);
|
| 2444 |
+
}, lowestPollingInterval)
|
| 2445 |
+
};
|
| 2446 |
+
}
|
| 2447 |
+
function updatePollingInterval({
|
| 2448 |
+
queryCacheKey
|
| 2449 |
+
}, api2) {
|
| 2450 |
+
const state = api2.getState()[reducerPath];
|
| 2451 |
+
const querySubState = state.queries[queryCacheKey];
|
| 2452 |
+
const subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
| 2453 |
+
if (!querySubState || querySubState.status === "uninitialized" /* uninitialized */) {
|
| 2454 |
+
return;
|
| 2455 |
+
}
|
| 2456 |
+
const {
|
| 2457 |
+
lowestPollingInterval
|
| 2458 |
+
} = findLowestPollingInterval(subscriptions);
|
| 2459 |
+
if (!Number.isFinite(lowestPollingInterval)) {
|
| 2460 |
+
cleanupPollForKey(queryCacheKey);
|
| 2461 |
+
return;
|
| 2462 |
+
}
|
| 2463 |
+
const currentPoll = currentPolls[queryCacheKey];
|
| 2464 |
+
const nextPollTimestamp = Date.now() + lowestPollingInterval;
|
| 2465 |
+
if (!currentPoll || nextPollTimestamp < currentPoll.nextPollTimestamp) {
|
| 2466 |
+
startNextPoll({
|
| 2467 |
+
queryCacheKey
|
| 2468 |
+
}, api2);
|
| 2469 |
+
}
|
| 2470 |
+
}
|
| 2471 |
+
function cleanupPollForKey(key) {
|
| 2472 |
+
const existingPoll = currentPolls[key];
|
| 2473 |
+
if (existingPoll?.timeout) {
|
| 2474 |
+
clearTimeout(existingPoll.timeout);
|
| 2475 |
+
}
|
| 2476 |
+
delete currentPolls[key];
|
| 2477 |
+
}
|
| 2478 |
+
function clearPolls() {
|
| 2479 |
+
for (const key of Object.keys(currentPolls)) {
|
| 2480 |
+
cleanupPollForKey(key);
|
| 2481 |
+
}
|
| 2482 |
+
}
|
| 2483 |
+
function findLowestPollingInterval(subscribers = {}) {
|
| 2484 |
+
let skipPollingIfUnfocused = false;
|
| 2485 |
+
let lowestPollingInterval = Number.POSITIVE_INFINITY;
|
| 2486 |
+
for (let key in subscribers) {
|
| 2487 |
+
if (!!subscribers[key].pollingInterval) {
|
| 2488 |
+
lowestPollingInterval = Math.min(subscribers[key].pollingInterval, lowestPollingInterval);
|
| 2489 |
+
skipPollingIfUnfocused = subscribers[key].skipPollingIfUnfocused || skipPollingIfUnfocused;
|
| 2490 |
+
}
|
| 2491 |
+
}
|
| 2492 |
+
return {
|
| 2493 |
+
lowestPollingInterval,
|
| 2494 |
+
skipPollingIfUnfocused
|
| 2495 |
+
};
|
| 2496 |
+
}
|
| 2497 |
+
return handler;
|
| 2498 |
+
};
|
| 2499 |
+
|
| 2500 |
+
// src/query/core/buildMiddleware/queryLifecycle.ts
|
| 2501 |
+
var buildQueryLifecycleHandler = ({
|
| 2502 |
+
api,
|
| 2503 |
+
context,
|
| 2504 |
+
queryThunk,
|
| 2505 |
+
mutationThunk
|
| 2506 |
+
}) => {
|
| 2507 |
+
const isPendingThunk = isPending(queryThunk, mutationThunk);
|
| 2508 |
+
const isRejectedThunk = isRejected(queryThunk, mutationThunk);
|
| 2509 |
+
const isFullfilledThunk = isFulfilled(queryThunk, mutationThunk);
|
| 2510 |
+
const lifecycleMap = {};
|
| 2511 |
+
const handler = (action, mwApi) => {
|
| 2512 |
+
if (isPendingThunk(action)) {
|
| 2513 |
+
const {
|
| 2514 |
+
requestId,
|
| 2515 |
+
arg: {
|
| 2516 |
+
endpointName,
|
| 2517 |
+
originalArgs
|
| 2518 |
+
}
|
| 2519 |
+
} = action.meta;
|
| 2520 |
+
const endpointDefinition = context.endpointDefinitions[endpointName];
|
| 2521 |
+
const onQueryStarted = endpointDefinition?.onQueryStarted;
|
| 2522 |
+
if (onQueryStarted) {
|
| 2523 |
+
const lifecycle = {};
|
| 2524 |
+
const queryFulfilled = new Promise((resolve, reject) => {
|
| 2525 |
+
lifecycle.resolve = resolve;
|
| 2526 |
+
lifecycle.reject = reject;
|
| 2527 |
+
});
|
| 2528 |
+
queryFulfilled.catch(() => {
|
| 2529 |
+
});
|
| 2530 |
+
lifecycleMap[requestId] = lifecycle;
|
| 2531 |
+
const selector = api.endpoints[endpointName].select(isAnyQueryDefinition(endpointDefinition) ? originalArgs : requestId);
|
| 2532 |
+
const extra = mwApi.dispatch((_, __, extra2) => extra2);
|
| 2533 |
+
const lifecycleApi = {
|
| 2534 |
+
...mwApi,
|
| 2535 |
+
getCacheEntry: () => selector(mwApi.getState()),
|
| 2536 |
+
requestId,
|
| 2537 |
+
extra,
|
| 2538 |
+
updateCachedData: isAnyQueryDefinition(endpointDefinition) ? (updateRecipe) => mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)) : void 0,
|
| 2539 |
+
queryFulfilled
|
| 2540 |
+
};
|
| 2541 |
+
onQueryStarted(originalArgs, lifecycleApi);
|
| 2542 |
+
}
|
| 2543 |
+
} else if (isFullfilledThunk(action)) {
|
| 2544 |
+
const {
|
| 2545 |
+
requestId,
|
| 2546 |
+
baseQueryMeta
|
| 2547 |
+
} = action.meta;
|
| 2548 |
+
lifecycleMap[requestId]?.resolve({
|
| 2549 |
+
data: action.payload,
|
| 2550 |
+
meta: baseQueryMeta
|
| 2551 |
+
});
|
| 2552 |
+
delete lifecycleMap[requestId];
|
| 2553 |
+
} else if (isRejectedThunk(action)) {
|
| 2554 |
+
const {
|
| 2555 |
+
requestId,
|
| 2556 |
+
rejectedWithValue,
|
| 2557 |
+
baseQueryMeta
|
| 2558 |
+
} = action.meta;
|
| 2559 |
+
lifecycleMap[requestId]?.reject({
|
| 2560 |
+
error: action.payload ?? action.error,
|
| 2561 |
+
isUnhandledError: !rejectedWithValue,
|
| 2562 |
+
meta: baseQueryMeta
|
| 2563 |
+
});
|
| 2564 |
+
delete lifecycleMap[requestId];
|
| 2565 |
+
}
|
| 2566 |
+
};
|
| 2567 |
+
return handler;
|
| 2568 |
+
};
|
| 2569 |
+
|
| 2570 |
+
// src/query/core/buildMiddleware/windowEventHandling.ts
|
| 2571 |
+
var buildWindowEventHandler = ({
|
| 2572 |
+
reducerPath,
|
| 2573 |
+
context,
|
| 2574 |
+
api,
|
| 2575 |
+
refetchQuery,
|
| 2576 |
+
internalState
|
| 2577 |
+
}) => {
|
| 2578 |
+
const {
|
| 2579 |
+
removeQueryResult
|
| 2580 |
+
} = api.internalActions;
|
| 2581 |
+
const handler = (action, mwApi) => {
|
| 2582 |
+
if (onFocus.match(action)) {
|
| 2583 |
+
refetchValidQueries(mwApi, "refetchOnFocus");
|
| 2584 |
+
}
|
| 2585 |
+
if (onOnline.match(action)) {
|
| 2586 |
+
refetchValidQueries(mwApi, "refetchOnReconnect");
|
| 2587 |
+
}
|
| 2588 |
+
};
|
| 2589 |
+
function refetchValidQueries(api2, type) {
|
| 2590 |
+
const state = api2.getState()[reducerPath];
|
| 2591 |
+
const queries = state.queries;
|
| 2592 |
+
const subscriptions = internalState.currentSubscriptions;
|
| 2593 |
+
context.batch(() => {
|
| 2594 |
+
for (const queryCacheKey of Object.keys(subscriptions)) {
|
| 2595 |
+
const querySubState = queries[queryCacheKey];
|
| 2596 |
+
const subscriptionSubState = subscriptions[queryCacheKey];
|
| 2597 |
+
if (!subscriptionSubState || !querySubState) continue;
|
| 2598 |
+
const shouldRefetch = Object.values(subscriptionSubState).some((sub) => sub[type] === true) || Object.values(subscriptionSubState).every((sub) => sub[type] === void 0) && state.config[type];
|
| 2599 |
+
if (shouldRefetch) {
|
| 2600 |
+
if (countObjectKeys(subscriptionSubState) === 0) {
|
| 2601 |
+
api2.dispatch(removeQueryResult({
|
| 2602 |
+
queryCacheKey
|
| 2603 |
+
}));
|
| 2604 |
+
} else if (querySubState.status !== "uninitialized" /* uninitialized */) {
|
| 2605 |
+
api2.dispatch(refetchQuery(querySubState));
|
| 2606 |
+
}
|
| 2607 |
+
}
|
| 2608 |
+
}
|
| 2609 |
+
});
|
| 2610 |
+
}
|
| 2611 |
+
return handler;
|
| 2612 |
+
};
|
| 2613 |
+
|
| 2614 |
+
// src/query/core/buildMiddleware/index.ts
|
| 2615 |
+
function buildMiddleware(input) {
|
| 2616 |
+
const {
|
| 2617 |
+
reducerPath,
|
| 2618 |
+
queryThunk,
|
| 2619 |
+
api,
|
| 2620 |
+
context
|
| 2621 |
+
} = input;
|
| 2622 |
+
const {
|
| 2623 |
+
apiUid
|
| 2624 |
+
} = context;
|
| 2625 |
+
const actions = {
|
| 2626 |
+
invalidateTags: createAction(`${reducerPath}/invalidateTags`)
|
| 2627 |
+
};
|
| 2628 |
+
const isThisApiSliceAction = (action) => action.type.startsWith(`${reducerPath}/`);
|
| 2629 |
+
const handlerBuilders = [buildDevCheckHandler, buildCacheCollectionHandler, buildInvalidationByTagsHandler, buildPollingHandler, buildCacheLifecycleHandler, buildQueryLifecycleHandler];
|
| 2630 |
+
const middleware = (mwApi) => {
|
| 2631 |
+
let initialized2 = false;
|
| 2632 |
+
const internalState = {
|
| 2633 |
+
currentSubscriptions: {}
|
| 2634 |
+
};
|
| 2635 |
+
const builderArgs = {
|
| 2636 |
+
...input,
|
| 2637 |
+
internalState,
|
| 2638 |
+
refetchQuery,
|
| 2639 |
+
isThisApiSliceAction
|
| 2640 |
+
};
|
| 2641 |
+
const handlers = handlerBuilders.map((build) => build(builderArgs));
|
| 2642 |
+
const batchedActionsHandler = buildBatchedActionsHandler(builderArgs);
|
| 2643 |
+
const windowEventsHandler = buildWindowEventHandler(builderArgs);
|
| 2644 |
+
return (next) => {
|
| 2645 |
+
return (action) => {
|
| 2646 |
+
if (!isAction(action)) {
|
| 2647 |
+
return next(action);
|
| 2648 |
+
}
|
| 2649 |
+
if (!initialized2) {
|
| 2650 |
+
initialized2 = true;
|
| 2651 |
+
mwApi.dispatch(api.internalActions.middlewareRegistered(apiUid));
|
| 2652 |
+
}
|
| 2653 |
+
const mwApiWithNext = {
|
| 2654 |
+
...mwApi,
|
| 2655 |
+
next
|
| 2656 |
+
};
|
| 2657 |
+
const stateBefore = mwApi.getState();
|
| 2658 |
+
const [actionShouldContinue, internalProbeResult] = batchedActionsHandler(action, mwApiWithNext, stateBefore);
|
| 2659 |
+
let res;
|
| 2660 |
+
if (actionShouldContinue) {
|
| 2661 |
+
res = next(action);
|
| 2662 |
+
} else {
|
| 2663 |
+
res = internalProbeResult;
|
| 2664 |
+
}
|
| 2665 |
+
if (!!mwApi.getState()[reducerPath]) {
|
| 2666 |
+
windowEventsHandler(action, mwApiWithNext, stateBefore);
|
| 2667 |
+
if (isThisApiSliceAction(action) || context.hasRehydrationInfo(action)) {
|
| 2668 |
+
for (const handler of handlers) {
|
| 2669 |
+
handler(action, mwApiWithNext, stateBefore);
|
| 2670 |
+
}
|
| 2671 |
+
}
|
| 2672 |
+
}
|
| 2673 |
+
return res;
|
| 2674 |
+
};
|
| 2675 |
+
};
|
| 2676 |
+
};
|
| 2677 |
+
return {
|
| 2678 |
+
middleware,
|
| 2679 |
+
actions
|
| 2680 |
+
};
|
| 2681 |
+
function refetchQuery(querySubState) {
|
| 2682 |
+
return input.api.endpoints[querySubState.endpointName].initiate(querySubState.originalArgs, {
|
| 2683 |
+
subscribe: false,
|
| 2684 |
+
forceRefetch: true
|
| 2685 |
+
});
|
| 2686 |
+
}
|
| 2687 |
+
}
|
| 2688 |
+
|
| 2689 |
+
// src/query/core/module.ts
|
| 2690 |
+
var coreModuleName = /* @__PURE__ */ Symbol();
|
| 2691 |
+
var coreModule = ({
|
| 2692 |
+
createSelector: createSelector2 = createSelector
|
| 2693 |
+
} = {}) => ({
|
| 2694 |
+
name: coreModuleName,
|
| 2695 |
+
init(api, {
|
| 2696 |
+
baseQuery,
|
| 2697 |
+
tagTypes,
|
| 2698 |
+
reducerPath,
|
| 2699 |
+
serializeQueryArgs,
|
| 2700 |
+
keepUnusedDataFor,
|
| 2701 |
+
refetchOnMountOrArgChange,
|
| 2702 |
+
refetchOnFocus,
|
| 2703 |
+
refetchOnReconnect,
|
| 2704 |
+
invalidationBehavior,
|
| 2705 |
+
onSchemaFailure,
|
| 2706 |
+
catchSchemaFailure,
|
| 2707 |
+
skipSchemaValidation
|
| 2708 |
+
}, context) {
|
| 2709 |
+
enablePatches();
|
| 2710 |
+
assertCast(serializeQueryArgs);
|
| 2711 |
+
const assertTagType = (tag) => {
|
| 2712 |
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
| 2713 |
+
if (!tagTypes.includes(tag.type)) {
|
| 2714 |
+
console.error(`Tag type '${tag.type}' was used, but not specified in \`tagTypes\`!`);
|
| 2715 |
+
}
|
| 2716 |
+
}
|
| 2717 |
+
return tag;
|
| 2718 |
+
};
|
| 2719 |
+
Object.assign(api, {
|
| 2720 |
+
reducerPath,
|
| 2721 |
+
endpoints: {},
|
| 2722 |
+
internalActions: {
|
| 2723 |
+
onOnline,
|
| 2724 |
+
onOffline,
|
| 2725 |
+
onFocus,
|
| 2726 |
+
onFocusLost
|
| 2727 |
+
},
|
| 2728 |
+
util: {}
|
| 2729 |
+
});
|
| 2730 |
+
const selectors = buildSelectors({
|
| 2731 |
+
serializeQueryArgs,
|
| 2732 |
+
reducerPath,
|
| 2733 |
+
createSelector: createSelector2
|
| 2734 |
+
});
|
| 2735 |
+
const {
|
| 2736 |
+
selectInvalidatedBy,
|
| 2737 |
+
selectCachedArgsForQuery,
|
| 2738 |
+
buildQuerySelector,
|
| 2739 |
+
buildInfiniteQuerySelector,
|
| 2740 |
+
buildMutationSelector
|
| 2741 |
+
} = selectors;
|
| 2742 |
+
safeAssign(api.util, {
|
| 2743 |
+
selectInvalidatedBy,
|
| 2744 |
+
selectCachedArgsForQuery
|
| 2745 |
+
});
|
| 2746 |
+
const {
|
| 2747 |
+
queryThunk,
|
| 2748 |
+
infiniteQueryThunk,
|
| 2749 |
+
mutationThunk,
|
| 2750 |
+
patchQueryData,
|
| 2751 |
+
updateQueryData,
|
| 2752 |
+
upsertQueryData,
|
| 2753 |
+
prefetch,
|
| 2754 |
+
buildMatchThunkActions
|
| 2755 |
+
} = buildThunks({
|
| 2756 |
+
baseQuery,
|
| 2757 |
+
reducerPath,
|
| 2758 |
+
context,
|
| 2759 |
+
api,
|
| 2760 |
+
serializeQueryArgs,
|
| 2761 |
+
assertTagType,
|
| 2762 |
+
selectors,
|
| 2763 |
+
onSchemaFailure,
|
| 2764 |
+
catchSchemaFailure,
|
| 2765 |
+
skipSchemaValidation
|
| 2766 |
+
});
|
| 2767 |
+
const {
|
| 2768 |
+
reducer,
|
| 2769 |
+
actions: sliceActions
|
| 2770 |
+
} = buildSlice({
|
| 2771 |
+
context,
|
| 2772 |
+
queryThunk,
|
| 2773 |
+
infiniteQueryThunk,
|
| 2774 |
+
mutationThunk,
|
| 2775 |
+
serializeQueryArgs,
|
| 2776 |
+
reducerPath,
|
| 2777 |
+
assertTagType,
|
| 2778 |
+
config: {
|
| 2779 |
+
refetchOnFocus,
|
| 2780 |
+
refetchOnReconnect,
|
| 2781 |
+
refetchOnMountOrArgChange,
|
| 2782 |
+
keepUnusedDataFor,
|
| 2783 |
+
reducerPath,
|
| 2784 |
+
invalidationBehavior
|
| 2785 |
+
}
|
| 2786 |
+
});
|
| 2787 |
+
safeAssign(api.util, {
|
| 2788 |
+
patchQueryData,
|
| 2789 |
+
updateQueryData,
|
| 2790 |
+
upsertQueryData,
|
| 2791 |
+
prefetch,
|
| 2792 |
+
resetApiState: sliceActions.resetApiState,
|
| 2793 |
+
upsertQueryEntries: sliceActions.cacheEntriesUpserted
|
| 2794 |
+
});
|
| 2795 |
+
safeAssign(api.internalActions, sliceActions);
|
| 2796 |
+
const {
|
| 2797 |
+
middleware,
|
| 2798 |
+
actions: middlewareActions
|
| 2799 |
+
} = buildMiddleware({
|
| 2800 |
+
reducerPath,
|
| 2801 |
+
context,
|
| 2802 |
+
queryThunk,
|
| 2803 |
+
mutationThunk,
|
| 2804 |
+
infiniteQueryThunk,
|
| 2805 |
+
api,
|
| 2806 |
+
assertTagType,
|
| 2807 |
+
selectors
|
| 2808 |
+
});
|
| 2809 |
+
safeAssign(api.util, middlewareActions);
|
| 2810 |
+
safeAssign(api, {
|
| 2811 |
+
reducer,
|
| 2812 |
+
middleware
|
| 2813 |
+
});
|
| 2814 |
+
const {
|
| 2815 |
+
buildInitiateQuery,
|
| 2816 |
+
buildInitiateInfiniteQuery,
|
| 2817 |
+
buildInitiateMutation,
|
| 2818 |
+
getRunningMutationThunk,
|
| 2819 |
+
getRunningMutationsThunk,
|
| 2820 |
+
getRunningQueriesThunk,
|
| 2821 |
+
getRunningQueryThunk
|
| 2822 |
+
} = buildInitiate({
|
| 2823 |
+
queryThunk,
|
| 2824 |
+
mutationThunk,
|
| 2825 |
+
infiniteQueryThunk,
|
| 2826 |
+
api,
|
| 2827 |
+
serializeQueryArgs,
|
| 2828 |
+
context
|
| 2829 |
+
});
|
| 2830 |
+
safeAssign(api.util, {
|
| 2831 |
+
getRunningMutationThunk,
|
| 2832 |
+
getRunningMutationsThunk,
|
| 2833 |
+
getRunningQueryThunk,
|
| 2834 |
+
getRunningQueriesThunk
|
| 2835 |
+
});
|
| 2836 |
+
return {
|
| 2837 |
+
name: coreModuleName,
|
| 2838 |
+
injectEndpoint(endpointName, definition) {
|
| 2839 |
+
const anyApi = api;
|
| 2840 |
+
const endpoint = anyApi.endpoints[endpointName] ??= {};
|
| 2841 |
+
if (isQueryDefinition(definition)) {
|
| 2842 |
+
safeAssign(endpoint, {
|
| 2843 |
+
name: endpointName,
|
| 2844 |
+
select: buildQuerySelector(endpointName, definition),
|
| 2845 |
+
initiate: buildInitiateQuery(endpointName, definition)
|
| 2846 |
+
}, buildMatchThunkActions(queryThunk, endpointName));
|
| 2847 |
+
}
|
| 2848 |
+
if (isMutationDefinition(definition)) {
|
| 2849 |
+
safeAssign(endpoint, {
|
| 2850 |
+
name: endpointName,
|
| 2851 |
+
select: buildMutationSelector(),
|
| 2852 |
+
initiate: buildInitiateMutation(endpointName)
|
| 2853 |
+
}, buildMatchThunkActions(mutationThunk, endpointName));
|
| 2854 |
+
}
|
| 2855 |
+
if (isInfiniteQueryDefinition(definition)) {
|
| 2856 |
+
safeAssign(endpoint, {
|
| 2857 |
+
name: endpointName,
|
| 2858 |
+
select: buildInfiniteQuerySelector(endpointName, definition),
|
| 2859 |
+
initiate: buildInitiateInfiniteQuery(endpointName, definition)
|
| 2860 |
+
}, buildMatchThunkActions(queryThunk, endpointName));
|
| 2861 |
+
}
|
| 2862 |
+
}
|
| 2863 |
+
};
|
| 2864 |
+
}
|
| 2865 |
+
});
|
| 2866 |
+
|
| 2867 |
+
// src/query/core/index.ts
|
| 2868 |
+
var createApi = /* @__PURE__ */ buildCreateApi(coreModule());
|
| 2869 |
+
export {
|
| 2870 |
+
NamedSchemaError,
|
| 2871 |
+
QueryStatus,
|
| 2872 |
+
_NEVER,
|
| 2873 |
+
buildCreateApi,
|
| 2874 |
+
copyWithStructuralSharing,
|
| 2875 |
+
coreModule,
|
| 2876 |
+
coreModuleName,
|
| 2877 |
+
createApi,
|
| 2878 |
+
defaultSerializeQueryArgs,
|
| 2879 |
+
fakeBaseQuery,
|
| 2880 |
+
fetchBaseQuery,
|
| 2881 |
+
retry,
|
| 2882 |
+
setupListeners,
|
| 2883 |
+
skipToken
|
| 2884 |
+
};
|
| 2885 |
+
//# sourceMappingURL=rtk-query.modern.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict'
|
| 2 |
+
if (process.env.NODE_ENV === 'production') {
|
| 3 |
+
module.exports = require('./redux-toolkit-react.production.min.cjs')
|
| 4 |
+
} else {
|
| 5 |
+
module.exports = require('./redux-toolkit-react.development.cjs')
|
| 6 |
+
}
|
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
| 19 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 20 |
+
|
| 21 |
+
// src/react/index.ts
|
| 22 |
+
var react_exports = {};
|
| 23 |
+
__export(react_exports, {
|
| 24 |
+
createDynamicMiddleware: () => createDynamicMiddleware
|
| 25 |
+
});
|
| 26 |
+
module.exports = __toCommonJS(react_exports);
|
| 27 |
+
__reExport(react_exports, require("@reduxjs/toolkit"), module.exports);
|
| 28 |
+
|
| 29 |
+
// src/dynamicMiddleware/react/index.ts
|
| 30 |
+
var import_toolkit = require("@reduxjs/toolkit");
|
| 31 |
+
var import_react_redux = require("react-redux");
|
| 32 |
+
var createDynamicMiddleware = () => {
|
| 33 |
+
const instance = (0, import_toolkit.createDynamicMiddleware)();
|
| 34 |
+
const createDispatchWithMiddlewareHookFactory = (context = import_react_redux.ReactReduxContext) => {
|
| 35 |
+
const useDispatch = context === import_react_redux.ReactReduxContext ? import_react_redux.useDispatch : (0, import_react_redux.createDispatchHook)(context);
|
| 36 |
+
function createDispatchWithMiddlewareHook2(...middlewares) {
|
| 37 |
+
instance.addMiddleware(...middlewares);
|
| 38 |
+
return useDispatch;
|
| 39 |
+
}
|
| 40 |
+
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
| 41 |
+
return createDispatchWithMiddlewareHook2;
|
| 42 |
+
};
|
| 43 |
+
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
| 44 |
+
return {
|
| 45 |
+
...instance,
|
| 46 |
+
createDispatchWithMiddlewareHookFactory,
|
| 47 |
+
createDispatchWithMiddlewareHook
|
| 48 |
+
};
|
| 49 |
+
};
|
| 50 |
+
// Annotate the CommonJS export names for ESM import in node:
|
| 51 |
+
0 && (module.exports = {
|
| 52 |
+
createDynamicMiddleware,
|
| 53 |
+
...require("@reduxjs/toolkit")
|
| 54 |
+
});
|
| 55 |
+
//# sourceMappingURL=redux-toolkit-react.development.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.development.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"]}
|
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"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")});
|
| 2 |
+
//# sourceMappingURL=redux-toolkit-react.production.min.cjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/react/cjs/redux-toolkit-react.production.min.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"]}
|
frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.mts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DynamicMiddlewareInstance, TSHelpersExtractDispatchExtensions, MiddlewareApiConfig, GetState, GetDispatch } from '@reduxjs/toolkit';
|
| 2 |
+
export * from '@reduxjs/toolkit';
|
| 3 |
+
import { Context } from 'react';
|
| 4 |
+
import { ReactReduxContextValue } from 'react-redux';
|
| 5 |
+
import { Dispatch, UnknownAction, Action, Middleware } from 'redux';
|
| 6 |
+
|
| 7 |
+
type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
| 8 |
+
type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
| 9 |
+
<Middlewares extends [
|
| 10 |
+
Middleware<any, State, DispatchType>,
|
| 11 |
+
...Middleware<any, State, DispatchType>[]
|
| 12 |
+
]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
| 13 |
+
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
| 14 |
+
};
|
| 15 |
+
type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
| 16 |
+
type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
| 17 |
+
createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
| 18 |
+
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
| 19 |
+
};
|
| 20 |
+
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
| 21 |
+
|
| 22 |
+
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
frontend/node_modules/@reduxjs/toolkit/dist/react/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DynamicMiddlewareInstance, TSHelpersExtractDispatchExtensions, MiddlewareApiConfig, GetState, GetDispatch } from '@reduxjs/toolkit';
|
| 2 |
+
export * from '@reduxjs/toolkit';
|
| 3 |
+
import { Context } from 'react';
|
| 4 |
+
import { ReactReduxContextValue } from 'react-redux';
|
| 5 |
+
import { Dispatch, UnknownAction, Action, Middleware } from 'redux';
|
| 6 |
+
|
| 7 |
+
type UseDispatchWithMiddlewareHook<Middlewares extends Middleware<any, State, DispatchType>[] = [], State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = () => TSHelpersExtractDispatchExtensions<Middlewares> & DispatchType;
|
| 8 |
+
type CreateDispatchWithMiddlewareHook<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = {
|
| 9 |
+
<Middlewares extends [
|
| 10 |
+
Middleware<any, State, DispatchType>,
|
| 11 |
+
...Middleware<any, State, DispatchType>[]
|
| 12 |
+
]>(...middlewares: Middlewares): UseDispatchWithMiddlewareHook<Middlewares, State, DispatchType>;
|
| 13 |
+
withTypes<MiddlewareConfig extends MiddlewareApiConfig>(): CreateDispatchWithMiddlewareHook<GetState<MiddlewareConfig>, GetDispatch<MiddlewareConfig>>;
|
| 14 |
+
};
|
| 15 |
+
type ActionFromDispatch<DispatchType extends Dispatch<Action>> = DispatchType extends Dispatch<infer Action> ? Action : never;
|
| 16 |
+
type ReactDynamicMiddlewareInstance<State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>> = DynamicMiddlewareInstance<State, DispatchType> & {
|
| 17 |
+
createDispatchWithMiddlewareHookFactory: (context?: Context<ReactReduxContextValue<State, ActionFromDispatch<DispatchType>> | null>) => CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
| 18 |
+
createDispatchWithMiddlewareHook: CreateDispatchWithMiddlewareHook<State, DispatchType>;
|
| 19 |
+
};
|
| 20 |
+
declare const createDynamicMiddleware: <State = any, DispatchType extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => ReactDynamicMiddlewareInstance<State, DispatchType>;
|
| 21 |
+
|
| 22 |
+
export { type CreateDispatchWithMiddlewareHook, createDynamicMiddleware };
|
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
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};
|
| 2 |
+
//# sourceMappingURL=redux-toolkit-react.browser.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.browser.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"]}
|
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var __defProp = Object.defineProperty;
|
| 2 |
+
var __defProps = Object.defineProperties;
|
| 3 |
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
| 4 |
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
| 7 |
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
| 8 |
+
var __spreadValues = (a, b) => {
|
| 9 |
+
for (var prop in b || (b = {}))
|
| 10 |
+
if (__hasOwnProp.call(b, prop))
|
| 11 |
+
__defNormalProp(a, prop, b[prop]);
|
| 12 |
+
if (__getOwnPropSymbols)
|
| 13 |
+
for (var prop of __getOwnPropSymbols(b)) {
|
| 14 |
+
if (__propIsEnum.call(b, prop))
|
| 15 |
+
__defNormalProp(a, prop, b[prop]);
|
| 16 |
+
}
|
| 17 |
+
return a;
|
| 18 |
+
};
|
| 19 |
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
| 20 |
+
|
| 21 |
+
// src/react/index.ts
|
| 22 |
+
export * from "@reduxjs/toolkit";
|
| 23 |
+
|
| 24 |
+
// src/dynamicMiddleware/react/index.ts
|
| 25 |
+
import { createDynamicMiddleware as cDM } from "@reduxjs/toolkit";
|
| 26 |
+
import { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from "react-redux";
|
| 27 |
+
var createDynamicMiddleware = () => {
|
| 28 |
+
const instance = cDM();
|
| 29 |
+
const createDispatchWithMiddlewareHookFactory = (context = ReactReduxContext) => {
|
| 30 |
+
const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);
|
| 31 |
+
function createDispatchWithMiddlewareHook2(...middlewares) {
|
| 32 |
+
instance.addMiddleware(...middlewares);
|
| 33 |
+
return useDispatch;
|
| 34 |
+
}
|
| 35 |
+
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
| 36 |
+
return createDispatchWithMiddlewareHook2;
|
| 37 |
+
};
|
| 38 |
+
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
| 39 |
+
return __spreadProps(__spreadValues({}, instance), {
|
| 40 |
+
createDispatchWithMiddlewareHookFactory,
|
| 41 |
+
createDispatchWithMiddlewareHook
|
| 42 |
+
});
|
| 43 |
+
};
|
| 44 |
+
export {
|
| 45 |
+
createDynamicMiddleware
|
| 46 |
+
};
|
| 47 |
+
//# sourceMappingURL=redux-toolkit-react.legacy-esm.js.map
|
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.legacy-esm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"]}
|
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// src/react/index.ts
|
| 2 |
+
export * from "@reduxjs/toolkit";
|
| 3 |
+
|
| 4 |
+
// src/dynamicMiddleware/react/index.ts
|
| 5 |
+
import { createDynamicMiddleware as cDM } from "@reduxjs/toolkit";
|
| 6 |
+
import { createDispatchHook, ReactReduxContext, useDispatch as useDefaultDispatch } from "react-redux";
|
| 7 |
+
var createDynamicMiddleware = () => {
|
| 8 |
+
const instance = cDM();
|
| 9 |
+
const createDispatchWithMiddlewareHookFactory = (context = ReactReduxContext) => {
|
| 10 |
+
const useDispatch = context === ReactReduxContext ? useDefaultDispatch : createDispatchHook(context);
|
| 11 |
+
function createDispatchWithMiddlewareHook2(...middlewares) {
|
| 12 |
+
instance.addMiddleware(...middlewares);
|
| 13 |
+
return useDispatch;
|
| 14 |
+
}
|
| 15 |
+
createDispatchWithMiddlewareHook2.withTypes = () => createDispatchWithMiddlewareHook2;
|
| 16 |
+
return createDispatchWithMiddlewareHook2;
|
| 17 |
+
};
|
| 18 |
+
const createDispatchWithMiddlewareHook = createDispatchWithMiddlewareHookFactory();
|
| 19 |
+
return {
|
| 20 |
+
...instance,
|
| 21 |
+
createDispatchWithMiddlewareHookFactory,
|
| 22 |
+
createDispatchWithMiddlewareHook
|
| 23 |
+
};
|
| 24 |
+
};
|
| 25 |
+
export {
|
| 26 |
+
createDynamicMiddleware
|
| 27 |
+
};
|
| 28 |
+
//# sourceMappingURL=redux-toolkit-react.modern.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/react/redux-toolkit-react.modern.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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"]}
|
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export*from"redux";import{produce as Io,current as vo,freeze as Do,original as Oo,isDraft as No}from"immer";import{createSelector as Fo,createSelectorCreator as Vo,lruMemoize as _o,weakMapMemoize as Lo}from"reselect";import{current as at,isDraft as it}from"immer";import{createSelectorCreator as st,weakMapMemoize as ct}from"reselect";var xe=(...e)=>{let t=st(...e),r=Object.assign((...n)=>{let o=t(...n),a=(s,...y)=>o(it(s)?at(s):s,...y);return Object.assign(a,o),a},{withTypes:()=>r});return r},ie=xe(ct);import{applyMiddleware as xt,createStore as Ct,compose as Et,combineReducers as Rt,isPlainObject as wt}from"redux";import{compose as Ce}from"redux";var Ee=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Ce:Ce.apply(null,arguments)},Rn=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}};import{thunk as mt,withExtraArgument as gt}from"redux-thunk";import{isAction as Re}from"redux";var q=e=>e&&typeof e.match=="function";function M(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(x(0));return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>Re(n)&&n.type===e,r}function se(e){return typeof e=="function"&&"type"in e&&q(e)}function ce(e){return Re(e)&&Object.keys(e).every(dt)}function dt(e){return["type","payload","error","meta"].indexOf(e)>-1}function ut(e){let t=e?`${e}`.split("/"):[],r=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched.
|
| 2 |
+
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${r}())\` instead of \`dispatch(${r})\`. This is necessary even if the action has no payload.`}function lt(e={}){return()=>r=>n=>r(n)}import{produce as pt,isDraftable as ft}from"immer";var F=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function de(e){return ft(e)?pt(e,()=>{}):e}function P(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function yt(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function ht(e={}){if(1)return()=>n=>o=>n(o);var t,r}import{isPlainObject as At}from"redux";function we(e){let t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||At(e)}function Me(e,t="",r=we,n,o=[],a){let s;if(!r(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||a?.has(e))return!1;let y=n!=null?n(e):Object.entries(e),c=o.length>0;for(let[l,i]of y){let d=t?t+"."+l:l;if(!(c&&o.some(g=>g instanceof RegExp?g.test(d):d===g))){if(!r(i))return{keyPath:d,value:i};if(typeof i=="object"&&(s=Me(i,d,r,n,o,a),s))return s}}return a&&Pe(e)&&a.add(e),!1}function Pe(e){if(!Object.isFrozen(e))return!1;for(let t of Object.values(e))if(!(typeof t!="object"||t===null)&&!Pe(t))return!1;return!0}function Tt(e={}){return()=>t=>r=>t(r)}function St(e){return typeof e=="boolean"}var be=()=>function(t){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:a=!0}=t??{},s=new F;return r&&(St(r)?s.push(mt):s.push(gt(r.extraArgument))),s};var ue="RTK_autoBatch",kt=()=>e=>({payload:e,meta:{[ue]:!0}}),Ie=e=>t=>{setTimeout(t,e)},le=(e={type:"raf"})=>t=>(...r)=>{let n=t(...r),o=!0,a=!1,s=!1,y=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Ie(10):e.type==="callback"?e.queueNotification:Ie(e.timeout),l=()=>{s=!1,a&&(a=!1,y.forEach(i=>i()))};return Object.assign({},n,{subscribe(i){let d=()=>o&&i(),T=n.subscribe(d);return y.add(i),()=>{T(),y.delete(i)}},dispatch(i){try{return o=!i?.meta?.[ue],a=!o,a&&(s||(s=!0,c(l))),n.dispatch(i)}finally{o=!0}}})};var ve=e=>function(r){let{autoBatch:n=!0}=r??{},o=new F(e);return n&&o.push(le(typeof n=="object"?n:void 0)),o};function Mt(e){let t=be(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:a=!0,preloadedState:s=void 0,enhancers:y=void 0}=e||{},c;if(typeof r=="function")c=r;else if(wt(r))c=Rt(r);else throw new Error(x(1));let l;typeof n=="function"?l=n(t):l=t();let i=Et;o&&(i=Ee({trace:!1,...typeof o=="object"&&o}));let d=xt(...l),T=ve(d),g=typeof y=="function"?y(T):T(),p=i(...g);return Ct(c,s,p)}import{produce as Pt,isDraft as bt,isDraftable as It}from"immer";function $(e){let t={},r=[],n,o={addCase(a,s){let y=typeof a=="string"?a:a.type;if(!y)throw new Error(x(28));if(y in t)throw new Error(x(29));return t[y]=s,o},addMatcher(a,s){return r.push({matcher:a,reducer:s}),o},addDefaultCase(a){return n=a,o}};return e(o),[t,r,n]}function vt(e){return typeof e=="function"}function pe(e,t){let[r,n,o]=$(t),a;if(vt(e))a=()=>de(e());else{let y=de(e);a=()=>y}function s(y=a(),c){let l=[r[c.type],...n.filter(({matcher:i})=>i(c)).map(({reducer:i})=>i)];return l.filter(i=>!!i).length===0&&(l=[o]),l.reduce((i,d)=>{if(d)if(bt(i)){let g=d(i,c);return g===void 0?i:g}else{if(It(i))return Pt(i,T=>d(T,c));{let T=d(i,c);if(T===void 0){if(i===null)return i;throw Error("A case reducer on a non-draftable value must not return undefined")}return T}}return i},y)}return s.getInitialState=a,s}var De=(e,t)=>q(e)?e.match(t):e(t);function V(...e){return t=>e.some(r=>De(r,t))}function W(...e){return t=>e.every(r=>De(r,t))}function J(e,t){if(!e||!e.meta)return!1;let r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function z(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function Oe(...e){return e.length===0?t=>J(t,["pending"]):z(e)?V(...e.map(t=>t.pending)):Oe()(e[0])}function X(...e){return e.length===0?t=>J(t,["rejected"]):z(e)?V(...e.map(t=>t.rejected)):X()(e[0])}function Ne(...e){let t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?W(X(...e),t):z(e)?W(X(...e),t):Ne()(e[0])}function je(...e){return e.length===0?t=>J(t,["fulfilled"]):z(e)?V(...e.map(t=>t.fulfilled)):je()(e[0])}function Fe(...e){return e.length===0?t=>J(t,["pending","fulfilled","rejected"]):z(e)?V(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):Fe()(e[0])}var Dt="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",I=(e=21)=>{let t="",r=e;for(;r--;)t+=Dt[Math.random()*64|0];return t};var Ot=["name","message","stack","code"],G=class{constructor(t,r){this.payload=t;this.meta=r}_type},Q=class{constructor(t,r){this.payload=t;this.meta=r}_type},_e=e=>{if(typeof e=="object"&&e!==null){let t={};for(let r of Ot)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},Ve="External signal was aborted",fe=(()=>{function e(t,r,n){let o=M(t+"/fulfilled",(c,l,i,d)=>({payload:c,meta:{...d||{},arg:i,requestId:l,requestStatus:"fulfilled"}})),a=M(t+"/pending",(c,l,i)=>({payload:void 0,meta:{...i||{},arg:l,requestId:c,requestStatus:"pending"}})),s=M(t+"/rejected",(c,l,i,d,T)=>({payload:d,error:(n&&n.serializeError||_e)(c||"Rejected"),meta:{...T||{},arg:i,requestId:l,rejectedWithValue:!!d,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"}}));function y(c,{signal:l}={}){return(i,d,T)=>{let g=n?.idGenerator?n.idGenerator(c):I(),p=new AbortController,h,u;function f(A){u=A,p.abort()}l&&(l.aborted?f(Ve):l.addEventListener("abort",()=>f(Ve),{once:!0}));let k=async function(){let A;try{let S=n?.condition?.(c,{getState:d,extra:T});if(Nt(S)&&(S=await S),S===!1||p.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let w=new Promise((C,E)=>{h=()=>{E({name:"AbortError",message:u||"Aborted"})},p.signal.addEventListener("abort",h)});i(a(g,c,n?.getPendingMeta?.({requestId:g,arg:c},{getState:d,extra:T}))),A=await Promise.race([w,Promise.resolve(r(c,{dispatch:i,getState:d,extra:T,requestId:g,signal:p.signal,abort:f,rejectWithValue:(C,E)=>new G(C,E),fulfillWithValue:(C,E)=>new Q(C,E)})).then(C=>{if(C instanceof G)throw C;return C instanceof Q?o(C.payload,g,c,C.meta):o(C,g,c)})])}catch(S){A=S instanceof G?s(null,g,c,S.payload,S.meta):s(S,g,c)}finally{h&&p.signal.removeEventListener("abort",h)}return n&&!n.dispatchConditionRejection&&s.match(A)&&A.meta.condition||i(A),A}();return Object.assign(k,{abort:f,requestId:g,arg:c,unwrap(){return k.then(Le)}})}}return Object.assign(y,{pending:a,rejected:s,fulfilled:o,settled:V(s,o),typePrefix:t})}return e.withTypes=()=>e,e})();function Le(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function Nt(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var Ue=Symbol.for("rtk-slice-createasyncthunk"),jt={[Ue]:fe},We=(n=>(n.reducer="reducer",n.reducerWithPrepare="reducerWithPrepare",n.asyncThunk="asyncThunk",n))(We||{});function Ft(e,t){return`${e}/${t}`}function ze({creators:e}={}){let t=e?.asyncThunk?.[Ue];return function(n){let{name:o,reducerPath:a=o}=n;if(!o)throw new Error(x(11));let s=(typeof n.reducers=="function"?n.reducers(Lt()):n.reducers)||{},y=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(A,m){let S=typeof A=="string"?A:A.type;if(!S)throw new Error(x(12));if(S in c.sliceCaseReducersByType)throw new Error(x(13));return c.sliceCaseReducersByType[S]=m,l},addMatcher(A,m){return c.sliceMatchers.push({matcher:A,reducer:m}),l},exposeAction(A,m){return c.actionCreators[A]=m,l},exposeCaseReducer(A,m){return c.sliceCaseReducersByName[A]=m,l}};y.forEach(A=>{let m=s[A],S={reducerName:A,type:Ft(o,A),createNotation:typeof n.reducers=="function"};Wt(m)?Gt(S,m,l,t):Ut(S,m,l)});function i(){let[A={},m=[],S=void 0]=typeof n.extraReducers=="function"?$(n.extraReducers):[n.extraReducers],w={...A,...c.sliceCaseReducersByType};return pe(n.initialState,C=>{for(let E in w)C.addCase(E,w[E]);for(let E of c.sliceMatchers)C.addMatcher(E.matcher,E.reducer);for(let E of m)C.addMatcher(E.matcher,E.reducer);S&&C.addDefaultCase(S)})}let d=A=>A,T=new Map,g=new WeakMap,p;function h(A,m){return p||(p=i()),p(A,m)}function u(){return p||(p=i()),p.getInitialState()}function f(A,m=!1){function S(C){let E=C[A];return typeof E>"u"&&m&&(E=P(g,S,u)),E}function w(C=d){let E=P(T,m,()=>new WeakMap);return P(E,C,()=>{let U={};for(let[H,j]of Object.entries(n.selectors??{}))U[H]=Vt(j,C,()=>P(g,C,u),m);return U})}return{reducerPath:A,getSelectors:w,get selectors(){return w(S)},selectSlice:S}}let k={name:o,reducer:h,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:u,...f(a),injectInto(A,{reducerPath:m,...S}={}){let w=m??a;return A.inject({reducerPath:w,reducer:h},S),{...k,...f(w,!0)}}};return k}}function Vt(e,t,r,n){function o(a,...s){let y=t(a);return typeof y>"u"&&n&&(y=r()),e(y,...s)}return o.unwrapped=e,o}var _t=ze();function Lt(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function Ut({type:e,reducerName:t,createNotation:r},n,o){let a,s;if("reducer"in n){if(r&&!zt(n))throw new Error(x(17));a=n.reducer,s=n.prepare}else a=n;o.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,s?M(e,s):M(e))}function Wt(e){return e._reducerDefinitionType==="asyncThunk"}function zt(e){return e._reducerDefinitionType==="reducerWithPrepare"}function Gt({type:e,reducerName:t},r,n,o){if(!o)throw new Error(x(18));let{payloadCreator:a,fulfilled:s,pending:y,rejected:c,settled:l,options:i}=r,d=o(e,a,i);n.exposeAction(t,d),s&&n.addCase(d.fulfilled,s),y&&n.addCase(d.pending,y),c&&n.addCase(d.rejected,c),l&&n.addMatcher(d.settled,l),n.exposeCaseReducer(t,{fulfilled:s||Y,pending:y||Y,rejected:c||Y,settled:l||Y})}function Y(){}function Bt(){return{ids:[],entities:{}}}function Ge(e){function t(r={},n){let o=Object.assign(Bt(),r);return n?e.setAll(o,n):o}return{getInitialState:t}}function Be(){function e(t,r={}){let{createSelector:n=ie}=r,o=d=>d.ids,a=d=>d.entities,s=n(o,a,(d,T)=>d.map(g=>T[g])),y=(d,T)=>T,c=(d,T)=>d[T],l=n(o,d=>d.length);if(!t)return{selectIds:o,selectEntities:a,selectAll:s,selectTotal:l,selectById:n(a,y,c)};let i=n(t,a);return{selectIds:n(t,o),selectEntities:i,selectAll:n(t,s),selectTotal:n(t,l),selectById:n(i,y,c)}}return{getSelectors:e}}import{produce as Kt,isDraft as Ht}from"immer";var qt=Ht;function Ke(e){let t=R((r,n)=>e(n));return function(n){return t(n,void 0)}}function R(e){return function(r,n){function o(s){return ce(s)}let a=s=>{o(n)?e(n.payload,s):e(n,s)};return qt(r)?(a(r),r):Kt(r,a)}}import{current as $t,isDraft as Xt}from"immer";function D(e,t){return t(e)}function v(e){return Array.isArray(e)||(e=Object.values(e)),e}function B(e){return Xt(e)?$t(e):e}function Z(e,t,r){e=v(e);let n=B(r.ids),o=new Set(n),a=[],s=new Set([]),y=[];for(let c of e){let l=D(c,t);o.has(l)||s.has(l)?y.push({id:l,changes:c}):(s.add(l),a.push(c))}return[a,y,n]}function ee(e){function t(p,h){let u=D(p,e);u in h.entities||(h.ids.push(u),h.entities[u]=p)}function r(p,h){p=v(p);for(let u of p)t(u,h)}function n(p,h){let u=D(p,e);u in h.entities||h.ids.push(u),h.entities[u]=p}function o(p,h){p=v(p);for(let u of p)n(u,h)}function a(p,h){p=v(p),h.ids=[],h.entities={},r(p,h)}function s(p,h){return y([p],h)}function y(p,h){let u=!1;p.forEach(f=>{f in h.entities&&(delete h.entities[f],u=!0)}),u&&(h.ids=h.ids.filter(f=>f in h.entities))}function c(p){Object.assign(p,{ids:[],entities:{}})}function l(p,h,u){let f=u.entities[h.id];if(f===void 0)return!1;let k=Object.assign({},f,h.changes),A=D(k,e),m=A!==h.id;return m&&(p[h.id]=A,delete u.entities[h.id]),u.entities[A]=k,m}function i(p,h){return d([p],h)}function d(p,h){let u={},f={};p.forEach(A=>{A.id in h.entities&&(f[A.id]={id:A.id,changes:{...f[A.id]?.changes,...A.changes}})}),p=Object.values(f),p.length>0&&p.filter(m=>l(u,m,h)).length>0&&(h.ids=Object.values(h.entities).map(m=>D(m,e)))}function T(p,h){return g([p],h)}function g(p,h){let[u,f]=Z(p,e,h);r(u,h),d(f,h)}return{removeAll:Ke(c),addOne:R(t),addMany:R(r),setOne:R(n),setMany:R(o),setAll:R(a),updateOne:R(i),updateMany:R(d),upsertOne:R(T),upsertMany:R(g),removeOne:R(s),removeMany:R(y)}}function Jt(e,t,r){let n=0,o=e.length;for(;n<o;){let a=n+o>>>1,s=e[a];r(t,s)>=0?n=a+1:o=a}return n}function Qt(e,t,r){let n=Jt(e,t,r);return e.splice(n,0,t),e}function He(e,t){let{removeOne:r,removeMany:n,removeAll:o}=ee(e);function a(u,f){return s([u],f)}function s(u,f,k){u=v(u);let A=new Set(k??B(f.ids)),m=u.filter(S=>!A.has(D(S,e)));m.length!==0&&h(f,m)}function y(u,f){return c([u],f)}function c(u,f){if(u=v(u),u.length!==0){for(let k of u)delete f.entities[e(k)];h(f,u)}}function l(u,f){u=v(u),f.entities={},f.ids=[],s(u,f,[])}function i(u,f){return d([u],f)}function d(u,f){let k=!1,A=!1;for(let m of u){let S=f.entities[m.id];if(!S)continue;k=!0,Object.assign(S,m.changes);let w=e(S);if(m.id!==w){A=!0,delete f.entities[m.id];let C=f.ids.indexOf(m.id);f.ids[C]=w,f.entities[w]=S}}k&&h(f,[],k,A)}function T(u,f){return g([u],f)}function g(u,f){let[k,A,m]=Z(u,e,f);k.length&&s(k,f,m),A.length&&d(A,f)}function p(u,f){if(u.length!==f.length)return!1;for(let k=0;k<u.length;k++)if(u[k]!==f[k])return!1;return!0}let h=(u,f,k,A)=>{let m=B(u.entities),S=B(u.ids),w=u.entities,C=S;A&&(C=new Set(S));let E=[];for(let j of C){let ke=m[j];ke&&E.push(ke)}let U=E.length===0;for(let j of f)w[e(j)]=j,U||Qt(E,j,t);U?E=f.slice().sort(t):k&&E.sort(t);let H=E.map(e);p(S,H)||(u.ids=H)};return{removeOne:r,removeMany:n,removeAll:o,addOne:R(a),updateOne:R(i),upsertOne:R(T),setOne:R(y),setMany:R(c),setAll:R(l),addMany:R(s),updateMany:R(d),upsertMany:R(g)}}function Yt(e={}){let{selectId:t,sortComparer:r}={sortComparer:!1,selectId:s=>s.id,...e},n=r?He(t,r):ee(t),o=Ge(n),a=Be();return{selectId:t,sortComparer:r,...o,...a,...n}}import{isAction as en}from"redux";var Zt="task",qe="listener",$e="completed",ye="cancelled",Xe=`task-${ye}`,Je=`task-${$e}`,te=`${qe}-${ye}`,Qe=`${qe}-${$e}`,b=class{constructor(t){this.code=t;this.message=`${Zt} ${ye} (reason: ${t})`}name="TaskAbortError";message};var ne=(e,t)=>{if(typeof e!="function")throw new TypeError(x(32))},_=()=>{},re=(e,t=_)=>(e.catch(t),e),oe=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),O=(e,t)=>{let r=e.signal;r.aborted||("reason"in r||Object.defineProperty(r,"reason",{enumerable:!0,value:t,configurable:!0,writable:!0}),e.abort(t))};var N=e=>{if(e.aborted){let{reason:t}=e;throw new b(t)}};function he(e,t){let r=_;return new Promise((n,o)=>{let a=()=>o(new b(e.reason));if(e.aborted){a();return}r=oe(e,a),t.finally(()=>r()).then(n,o)}).finally(()=>{r=_})}var Ye=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(r){return{status:r instanceof b?"cancelled":"rejected",error:r}}finally{t?.()}},K=e=>t=>re(he(e,t).then(r=>(N(e),r))),Ae=e=>{let t=K(e);return r=>t(new Promise(n=>setTimeout(n,r)))};var{assign:L}=Object,Ze={},ae="listenerMiddleware",tn=(e,t)=>{let r=n=>oe(e,()=>O(n,e.reason));return(n,o)=>{ne(n,"taskExecutor");let a=new AbortController;r(a);let s=Ye(async()=>{N(e),N(a.signal);let y=await n({pause:K(a.signal),delay:Ae(a.signal),signal:a.signal});return N(a.signal),y},()=>O(a,Je));return o?.autoJoin&&t.push(s.catch(_)),{result:K(e)(s),cancel(){O(a,Xe)}}}},nn=(e,t)=>{let r=async(n,o)=>{N(t);let a=()=>{},y=[new Promise((c,l)=>{let i=e({predicate:n,effect:(d,T)=>{T.unsubscribe(),c([d,T.getState(),T.getOriginalState()])}});a=()=>{i(),l()}})];o!=null&&y.push(new Promise(c=>setTimeout(c,o,null)));try{let c=await he(t,Promise.race(y));return N(t),c}finally{a()}};return(n,o)=>re(r(n,o))},nt=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:a}=e;if(t)o=M(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(x(21));return ne(a,"options.listener"),{predicate:o,type:t,effect:a}},rt=L(e=>{let{type:t,predicate:r,effect:n}=nt(e);return{id:I(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(x(22))}}},{withTypes:()=>rt}),et=(e,t)=>{let{type:r,effect:n,predicate:o}=nt(t);return Array.from(e.values()).find(a=>(typeof r=="string"?a.type===r:a.predicate===o)&&a.effect===n)},Te=e=>{e.pending.forEach(t=>{O(t,te)})},rn=e=>()=>{e.forEach(Te),e.clear()},tt=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},me=L(M(`${ae}/add`),{withTypes:()=>me}),ot=M(`${ae}/removeAll`),ge=L(M(`${ae}/remove`),{withTypes:()=>ge}),on=(...e)=>{console.error(`${ae}/error`,...e)},an=(e={})=>{let t=new Map,{extra:r,onError:n=on}=e;ne(n,"onError");let o=i=>(i.unsubscribe=()=>t.delete(i.id),t.set(i.id,i),d=>{i.unsubscribe(),d?.cancelActive&&Te(i)}),a=i=>{let d=et(t,i)??rt(i);return o(d)};L(a,{withTypes:()=>a});let s=i=>{let d=et(t,i);return d&&(d.unsubscribe(),i.cancelActive&&Te(d)),!!d};L(s,{withTypes:()=>s});let y=async(i,d,T,g)=>{let p=new AbortController,h=nn(a,p.signal),u=[];try{i.pending.add(p),await Promise.resolve(i.effect(d,L({},T,{getOriginalState:g,condition:(f,k)=>h(f,k).then(Boolean),take:h,delay:Ae(p.signal),pause:K(p.signal),extra:r,signal:p.signal,fork:tn(p.signal,u),unsubscribe:i.unsubscribe,subscribe:()=>{t.set(i.id,i)},cancelActiveListeners:()=>{i.pending.forEach((f,k,A)=>{f!==p&&(O(f,te),A.delete(f))})},cancel:()=>{O(p,te),i.pending.delete(p)},throwIfCancelled:()=>{N(p.signal)}})))}catch(f){f instanceof b||tt(n,f,{raisedBy:"effect"})}finally{await Promise.all(u),O(p,Qe),i.pending.delete(p)}},c=rn(t);return{middleware:i=>d=>T=>{if(!en(T))return d(T);if(me.match(T))return a(T.payload);if(ot.match(T)){c();return}if(ge.match(T))return s(T.payload);let g=i.getState(),p=()=>{if(g===Ze)throw new Error(x(23));return g},h;try{if(h=d(T),t.size>0){let u=i.getState(),f=Array.from(t.values());for(let k of f){let A=!1;try{A=k.predicate(T,u,g)}catch(m){A=!1,tt(n,m,{raisedBy:"predicate"})}A&&y(k,T,i,p)}}}finally{g=Ze}return h},startListening:a,stopListening:s,clearListeners:c}};import{compose as sn}from"redux";var cn=e=>({middleware:e,applied:new Map}),dn=e=>t=>t?.meta?.instanceId===e,un=()=>{let e=I(),t=new Map,r=Object.assign(M("dynamicMiddleware/add",(...y)=>({payload:y,meta:{instanceId:e}})),{withTypes:()=>r}),n=Object.assign(function(...c){c.forEach(l=>{P(t,l,cn)})},{withTypes:()=>n}),o=y=>{let c=Array.from(t.values()).map(l=>P(l.applied,y,l.middleware));return sn(...c)},a=W(r,dn(e));return{middleware:y=>c=>l=>a(l)?(n(...l.payload),y.dispatch):o(y)(c)(l),addMiddleware:n,withMiddleware:r,instanceId:e}};import{combineReducers as ln}from"redux";var pn=e=>"reducerPath"in e&&typeof e.reducerPath=="string",fn=e=>e.flatMap(t=>pn(t)?[[t.reducerPath,t.reducer]]:Object.entries(t)),Se=Symbol.for("rtk-state-proxy-original"),yn=e=>!!e&&!!e[Se],hn=new WeakMap,An=(e,t,r)=>P(hn,e,()=>new Proxy(e,{get:(n,o,a)=>{if(o===Se)return n;let s=Reflect.get(n,o,a);if(typeof s>"u"){let y=r[o];if(typeof y<"u")return y;let c=t[o];if(c){let l=c(void 0,{type:I()});if(typeof l>"u")throw new Error(x(24));return r[o]=l,l}}return s}})),Tn=e=>{if(!yn(e))throw new Error(x(25));return e[Se]},mn={},gn=(e=mn)=>e;function Sn(...e){let t=Object.fromEntries(fn(e)),r=()=>Object.keys(t).length?ln(t):gn,n=r();function o(c,l){return n(c,l)}o.withLazyLoadedSlices=()=>o;let a={},s=(c,l={})=>{let{reducerPath:i,reducer:d}=c,T=t[i];return!l.overrideExisting&&T&&T!==d||(l.overrideExisting&&T!==d&&delete a[i],t[i]=d,n=r()),o},y=Object.assign(function(l,i){return function(T,...g){return l(An(i?i(T,...g):T,t,a),...g)}},{original:Tn});return Object.assign(o,{inject:s,selector:y})}function x(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}export{We as ReducerType,ue as SHOULD_AUTOBATCH,b as TaskAbortError,F as Tuple,me as addListener,jt as asyncThunkCreator,le as autoBatchEnhancer,ze as buildCreateSlice,ot as clearAllListeners,Sn as combineSlices,Mt as configureStore,M as createAction,lt as createActionCreatorInvariantMiddleware,fe as createAsyncThunk,ie as createDraftSafeSelector,xe as createDraftSafeSelectorCreator,un as createDynamicMiddleware,Yt as createEntityAdapter,ht as createImmutableStateInvariantMiddleware,an as createListenerMiddleware,Io as createNextState,pe as createReducer,Fo as createSelector,Vo as createSelectorCreator,Tt as createSerializableStateInvariantMiddleware,_t as createSlice,vo as current,Me as findNonSerializableValue,x as formatProdErrorMessage,Do as freeze,se as isActionCreator,W as isAllOf,V as isAnyOf,Fe as isAsyncThunkAction,No as isDraft,ce as isFluxStandardAction,je as isFulfilled,yt as isImmutableDefault,Oe as isPending,we as isPlain,X as isRejected,Ne as isRejectedWithValue,_o as lruMemoize,_e as miniSerializeError,I as nanoid,Oo as original,kt as prepareAutoBatched,ge as removeListener,Le as unwrapResult,Lo as weakMapMemoize};
|
| 3 |
+
//# sourceMappingURL=redux-toolkit.browser.mjs.map
|
frontend/node_modules/@reduxjs/toolkit/dist/redux-toolkit.browser.mjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|