| @@ -1,12 +1,286 @@ | ||
| 1 | 1 | /******/ (function() { // webpackBootstrap |
| 2 | 2 | /******/ "use strict"; |
| 3 | 3 | /******/ var __webpack_modules__ = ({ |
| 4 | 4 | |
| 5 | -/***/ "./node_modules/@tanstack/query-core/build/modern/focusManager.js": | |
| 6 | -/*!************************************************************************!*\ | |
| 7 | - !*** ./node_modules/@tanstack/query-core/build/modern/focusManager.js ***! | |
| 8 | - \************************************************************************/ | |
| 5 | +/***/ "./node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js": | |
| 6 | +/*!**********************************************************************************************!*\ | |
| 7 | + !*** ./node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js ***! | |
| 8 | + \**********************************************************************************************/ | |
| 9 | +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * @license React | |
| 13 | + * use-sync-external-store-shim.development.js | |
| 14 | + * | |
| 15 | + * Copyright (c) Facebook, Inc. and its affiliates. | |
| 16 | + * | |
| 17 | + * This source code is licensed under the MIT license found in the | |
| 18 | + * LICENSE file in the root directory of this source tree. | |
| 19 | + */ | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | +if (true) { | |
| 24 | + (function() { | |
| 25 | + | |
| 26 | + 'use strict'; | |
| 27 | + | |
| 28 | +/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | |
| 29 | +if ( | |
| 30 | + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | |
| 31 | + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === | |
| 32 | + 'function' | |
| 33 | +) { | |
| 34 | + __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); | |
| 35 | +} | |
| 36 | + var React = __webpack_require__(/*! react */ "react"); | |
| 37 | + | |
| 38 | +var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | |
| 39 | + | |
| 40 | +function error(format) { | |
| 41 | + { | |
| 42 | + { | |
| 43 | + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | |
| 44 | + args[_key2 - 1] = arguments[_key2]; | |
| 45 | + } | |
| 46 | + | |
| 47 | + printWarning('error', format, args); | |
| 48 | + } | |
| 49 | + } | |
| 50 | +} | |
| 51 | + | |
| 52 | +function printWarning(level, format, args) { | |
| 53 | + // When changing this logic, you might want to also | |
| 54 | + // update consoleWithStackDev.www.js as well. | |
| 55 | + { | |
| 56 | + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | |
| 57 | + var stack = ReactDebugCurrentFrame.getStackAddendum(); | |
| 58 | + | |
| 59 | + if (stack !== '') { | |
| 60 | + format += '%s'; | |
| 61 | + args = args.concat([stack]); | |
| 62 | + } // eslint-disable-next-line react-internal/safe-string-coercion | |
| 63 | + | |
| 64 | + | |
| 65 | + var argsWithFormat = args.map(function (item) { | |
| 66 | + return String(item); | |
| 67 | + }); // Careful: RN currently depends on this prefix | |
| 68 | + | |
| 69 | + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | |
| 70 | + // breaks IE9: https://github.com/facebook/react/issues/13610 | |
| 71 | + // eslint-disable-next-line react-internal/no-production-logging | |
| 72 | + | |
| 73 | + Function.prototype.apply.call(console[level], console, argsWithFormat); | |
| 74 | + } | |
| 75 | +} | |
| 76 | + | |
| 77 | +/** | |
| 78 | + * inlined Object.is polyfill to avoid requiring consumers ship their own | |
| 79 | + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | |
| 80 | + */ | |
| 81 | +function is(x, y) { | |
| 82 | + return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare | |
| 83 | + ; | |
| 84 | +} | |
| 85 | + | |
| 86 | +var objectIs = typeof Object.is === 'function' ? Object.is : is; | |
| 87 | + | |
| 88 | +// dispatch for CommonJS interop named imports. | |
| 89 | + | |
| 90 | +var useState = React.useState, | |
| 91 | + useEffect = React.useEffect, | |
| 92 | + useLayoutEffect = React.useLayoutEffect, | |
| 93 | + useDebugValue = React.useDebugValue; | |
| 94 | +var didWarnOld18Alpha = false; | |
| 95 | +var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works | |
| 96 | +// because of a very particular set of implementation details and assumptions | |
| 97 | +// -- change any one of them and it will break. The most important assumption | |
| 98 | +// is that updates are always synchronous, because concurrent rendering is | |
| 99 | +// only available in versions of React that also have a built-in | |
| 100 | +// useSyncExternalStore API. And we only use this shim when the built-in API | |
| 101 | +// does not exist. | |
| 102 | +// | |
| 103 | +// Do not assume that the clever hacks used by this hook also work in general. | |
| 104 | +// The point of this shim is to replace the need for hacks by other libraries. | |
| 105 | + | |
| 106 | +function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of | |
| 107 | +// React do not expose a way to check if we're hydrating. So users of the shim | |
| 108 | +// will need to track that themselves and return the correct value | |
| 109 | +// from `getSnapshot`. | |
| 110 | +getServerSnapshot) { | |
| 111 | + { | |
| 112 | + if (!didWarnOld18Alpha) { | |
| 113 | + if (React.startTransition !== undefined) { | |
| 114 | + didWarnOld18Alpha = true; | |
| 115 | + | |
| 116 | + error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.'); | |
| 117 | + } | |
| 118 | + } | |
| 119 | + } // Read the current snapshot from the store on every render. Again, this | |
| 120 | + // breaks the rules of React, and only works here because of specific | |
| 121 | + // implementation details, most importantly that updates are | |
| 122 | + // always synchronous. | |
| 123 | + | |
| 124 | + | |
| 125 | + var value = getSnapshot(); | |
| 126 | + | |
| 127 | + { | |
| 128 | + if (!didWarnUncachedGetSnapshot) { | |
| 129 | + var cachedValue = getSnapshot(); | |
| 130 | + | |
| 131 | + if (!objectIs(value, cachedValue)) { | |
| 132 | + error('The result of getSnapshot should be cached to avoid an infinite loop'); | |
| 133 | + | |
| 134 | + didWarnUncachedGetSnapshot = true; | |
| 135 | + } | |
| 136 | + } | |
| 137 | + } // Because updates are synchronous, we don't queue them. Instead we force a | |
| 138 | + // re-render whenever the subscribed state changes by updating an some | |
| 139 | + // arbitrary useState hook. Then, during render, we call getSnapshot to read | |
| 140 | + // the current value. | |
| 141 | + // | |
| 142 | + // Because we don't actually use the state returned by the useState hook, we | |
| 143 | + // can save a bit of memory by storing other stuff in that slot. | |
| 144 | + // | |
| 145 | + // To implement the early bailout, we need to track some things on a mutable | |
| 146 | + // object. Usually, we would put that in a useRef hook, but we can stash it in | |
| 147 | + // our useState hook instead. | |
| 148 | + // | |
| 149 | + // To force a re-render, we call forceUpdate({inst}). That works because the | |
| 150 | + // new object always fails an equality check. | |
| 151 | + | |
| 152 | + | |
| 153 | + var _useState = useState({ | |
| 154 | + inst: { | |
| 155 | + value: value, | |
| 156 | + getSnapshot: getSnapshot | |
| 157 | + } | |
| 158 | + }), | |
| 159 | + inst = _useState[0].inst, | |
| 160 | + forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated | |
| 161 | + // in the layout phase so we can access it during the tearing check that | |
| 162 | + // happens on subscribe. | |
| 163 | + | |
| 164 | + | |
| 165 | + useLayoutEffect(function () { | |
| 166 | + inst.value = value; | |
| 167 | + inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the | |
| 168 | + // commit phase if there was an interleaved mutation. In concurrent mode | |
| 169 | + // this can happen all the time, but even in synchronous mode, an earlier | |
| 170 | + // effect may have mutated the store. | |
| 171 | + | |
| 172 | + if (checkIfSnapshotChanged(inst)) { | |
| 173 | + // Force a re-render. | |
| 174 | + forceUpdate({ | |
| 175 | + inst: inst | |
| 176 | + }); | |
| 177 | + } | |
| 178 | + }, [subscribe, value, getSnapshot]); | |
| 179 | + useEffect(function () { | |
| 180 | + // Check for changes right before subscribing. Subsequent changes will be | |
| 181 | + // detected in the subscription handler. | |
| 182 | + if (checkIfSnapshotChanged(inst)) { | |
| 183 | + // Force a re-render. | |
| 184 | + forceUpdate({ | |
| 185 | + inst: inst | |
| 186 | + }); | |
| 187 | + } | |
| 188 | + | |
| 189 | + var handleStoreChange = function () { | |
| 190 | + // TODO: Because there is no cross-renderer API for batching updates, it's | |
| 191 | + // up to the consumer of this library to wrap their subscription event | |
| 192 | + // with unstable_batchedUpdates. Should we try to detect when this isn't | |
| 193 | + // the case and print a warning in development? | |
| 194 | + // The store changed. Check if the snapshot changed since the last time we | |
| 195 | + // read from the store. | |
| 196 | + if (checkIfSnapshotChanged(inst)) { | |
| 197 | + // Force a re-render. | |
| 198 | + forceUpdate({ | |
| 199 | + inst: inst | |
| 200 | + }); | |
| 201 | + } | |
| 202 | + }; // Subscribe to the store and return a clean-up function. | |
| 203 | + | |
| 204 | + | |
| 205 | + return subscribe(handleStoreChange); | |
| 206 | + }, [subscribe]); | |
| 207 | + useDebugValue(value); | |
| 208 | + return value; | |
| 209 | +} | |
| 210 | + | |
| 211 | +function checkIfSnapshotChanged(inst) { | |
| 212 | + var latestGetSnapshot = inst.getSnapshot; | |
| 213 | + var prevValue = inst.value; | |
| 214 | + | |
| 215 | + try { | |
| 216 | + var nextValue = latestGetSnapshot(); | |
| 217 | + return !objectIs(prevValue, nextValue); | |
| 218 | + } catch (error) { | |
| 219 | + return true; | |
| 220 | + } | |
| 221 | +} | |
| 222 | + | |
| 223 | +function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) { | |
| 224 | + // Note: The shim does not use getServerSnapshot, because pre-18 versions of | |
| 225 | + // React do not expose a way to check if we're hydrating. So users of the shim | |
| 226 | + // will need to track that themselves and return the correct value | |
| 227 | + // from `getSnapshot`. | |
| 228 | + return getSnapshot(); | |
| 229 | +} | |
| 230 | + | |
| 231 | +var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'); | |
| 232 | + | |
| 233 | +var isServerEnvironment = !canUseDOM; | |
| 234 | + | |
| 235 | +var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore; | |
| 236 | +var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim; | |
| 237 | + | |
| 238 | +exports.useSyncExternalStore = useSyncExternalStore$2; | |
| 239 | + /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | |
| 240 | +if ( | |
| 241 | + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | |
| 242 | + typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === | |
| 243 | + 'function' | |
| 244 | +) { | |
| 245 | + __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); | |
| 246 | +} | |
| 247 | + | |
| 248 | + })(); | |
| 249 | +} | |
| 250 | + | |
| 251 | + | |
| 252 | +/***/ }), | |
| 253 | + | |
| 254 | +/***/ "./node_modules/use-sync-external-store/shim/index.js": | |
| 255 | +/*!************************************************************!*\ | |
| 256 | + !*** ./node_modules/use-sync-external-store/shim/index.js ***! | |
| 257 | + \************************************************************/ | |
| 258 | +/***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | +if (false) {} else { | |
| 263 | + module.exports = __webpack_require__(/*! ../cjs/use-sync-external-store-shim.development.js */ "./node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"); | |
| 264 | +} | |
| 265 | + | |
| 266 | + | |
| 267 | +/***/ }), | |
| 268 | + | |
| 269 | +/***/ "react": | |
| 270 | +/*!**************************!*\ | |
| 271 | + !*** external ["React"] ***! | |
| 272 | + \**************************/ | |
| 273 | +/***/ (function(module) { | |
| 274 | + | |
| 275 | +module.exports = window["React"]; | |
| 276 | + | |
| 277 | +/***/ }), | |
| 278 | + | |
| 279 | +/***/ "./node_modules/@tanstack/query-core/build/lib/focusManager.mjs": | |
| 280 | +/*!**********************************************************************!*\ | |
| 281 | + !*** ./node_modules/@tanstack/query-core/build/lib/focusManager.mjs ***! | |
| 282 | + \**********************************************************************/ | |
| 9 | 283 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 10 | 284 | |
| 11 | 285 | __webpack_require__.r(__webpack_exports__); |
| 12 | 286 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -12,46 +286,59 @@ | ||
| 12 | 286 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 | 287 | /* harmony export */ FocusManager: function() { return /* binding */ FocusManager; }, |
| 14 | 288 | /* harmony export */ focusManager: function() { return /* binding */ focusManager; } |
| 15 | 289 | /* harmony export */ }); |
| 16 | -/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); | |
| 17 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 18 | -// src/focusManager.ts | |
| 290 | +/* harmony import */ var _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.mjs */ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs"); | |
| 291 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 19 | 292 | |
| 20 | 293 | |
| 21 | -var FocusManager = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 22 | - #focused; | |
| 23 | - #cleanup; | |
| 24 | - #setup; | |
| 294 | + | |
| 295 | +class FocusManager extends _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 25 | 296 | constructor() { |
| 26 | 297 | super(); |
| 27 | - this.#setup = (onFocus) => { | |
| 28 | - if (!_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { | |
| 29 | - const listener = () => onFocus(); | |
| 30 | - window.addEventListener("visibilitychange", listener, false); | |
| 298 | + | |
| 299 | + this.setup = onFocus => { | |
| 300 | + // addEventListener does not exist in React Native, but window does | |
| 301 | + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | |
| 302 | + if (!_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { | |
| 303 | + const listener = () => onFocus(); // Listen to visibillitychange and focus | |
| 304 | + | |
| 305 | + | |
| 306 | + window.addEventListener('visibilitychange', listener, false); | |
| 307 | + window.addEventListener('focus', listener, false); | |
| 31 | 308 | return () => { |
| 32 | - window.removeEventListener("visibilitychange", listener); | |
| 309 | + // Be sure to unsubscribe if a new handler is set | |
| 310 | + window.removeEventListener('visibilitychange', listener); | |
| 311 | + window.removeEventListener('focus', listener); | |
| 33 | 312 | }; |
| 34 | 313 | } |
| 314 | + | |
| 35 | 315 | return; |
| 36 | 316 | }; |
| 37 | 317 | } |
| 318 | + | |
| 38 | 319 | onSubscribe() { |
| 39 | - if (!this.#cleanup) { | |
| 40 | - this.setEventListener(this.#setup); | |
| 320 | + if (!this.cleanup) { | |
| 321 | + this.setEventListener(this.setup); | |
| 41 | 322 | } |
| 42 | 323 | } |
| 324 | + | |
| 43 | 325 | onUnsubscribe() { |
| 44 | 326 | if (!this.hasListeners()) { |
| 45 | - this.#cleanup?.(); | |
| 46 | - this.#cleanup = void 0; | |
| 327 | + var _this$cleanup; | |
| 328 | + | |
| 329 | + (_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this); | |
| 330 | + this.cleanup = undefined; | |
| 47 | 331 | } |
| 48 | 332 | } |
| 333 | + | |
| 49 | 334 | setEventListener(setup) { |
| 50 | - this.#setup = setup; | |
| 51 | - this.#cleanup?.(); | |
| 52 | - this.#cleanup = setup((focused) => { | |
| 53 | - if (typeof focused === "boolean") { | |
| 335 | + var _this$cleanup2; | |
| 336 | + | |
| 337 | + this.setup = setup; | |
| 338 | + (_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this); | |
| 339 | + this.cleanup = setup(focused => { | |
| 340 | + if (typeof focused === 'boolean') { | |
| 54 | 341 | this.setFocused(focused); |
| 55 | 342 | } else { |
| 56 | 343 | this.onFocus(); |
| 57 | 344 | } |
| @@ -56,245 +343,234 @@ | ||
| 56 | 343 | this.onFocus(); |
| 57 | 344 | } |
| 58 | 345 | }); |
| 59 | 346 | } |
| 347 | + | |
| 60 | 348 | setFocused(focused) { |
| 61 | - const changed = this.#focused !== focused; | |
| 349 | + const changed = this.focused !== focused; | |
| 350 | + | |
| 62 | 351 | if (changed) { |
| 63 | - this.#focused = focused; | |
| 352 | + this.focused = focused; | |
| 64 | 353 | this.onFocus(); |
| 65 | 354 | } |
| 66 | 355 | } |
| 356 | + | |
| 67 | 357 | onFocus() { |
| 68 | - const isFocused = this.isFocused(); | |
| 69 | - this.listeners.forEach((listener) => { | |
| 70 | - listener(isFocused); | |
| 358 | + this.listeners.forEach(({ | |
| 359 | + listener | |
| 360 | + }) => { | |
| 361 | + listener(); | |
| 71 | 362 | }); |
| 72 | 363 | } |
| 364 | + | |
| 73 | 365 | isFocused() { |
| 74 | - if (typeof this.#focused === "boolean") { | |
| 75 | - return this.#focused; | |
| 366 | + if (typeof this.focused === 'boolean') { | |
| 367 | + return this.focused; | |
| 368 | + } // document global can be unavailable in react native | |
| 369 | + | |
| 370 | + | |
| 371 | + if (typeof document === 'undefined') { | |
| 372 | + return true; | |
| 76 | 373 | } |
| 77 | - return globalThis.document?.visibilityState !== "hidden"; | |
| 374 | + | |
| 375 | + return [undefined, 'visible', 'prerender'].includes(document.visibilityState); | |
| 78 | 376 | } |
| 79 | -}; | |
| 80 | -var focusManager = new FocusManager(); | |
| 81 | 377 | |
| 82 | -//# sourceMappingURL=focusManager.js.map | |
| 378 | +} | |
| 379 | +const focusManager = new FocusManager(); | |
| 83 | 380 | |
| 381 | + | |
| 382 | +//# sourceMappingURL=focusManager.mjs.map | |
| 383 | + | |
| 384 | + | |
| 84 | 385 | /***/ }), |
| 85 | 386 | |
| 86 | -/***/ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js": | |
| 87 | -/*!*********************************************************************************!*\ | |
| 88 | - !*** ./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js ***! | |
| 89 | - \*********************************************************************************/ | |
| 387 | +/***/ "./node_modules/@tanstack/query-core/build/lib/infiniteQueryBehavior.mjs": | |
| 388 | +/*!*******************************************************************************!*\ | |
| 389 | + !*** ./node_modules/@tanstack/query-core/build/lib/infiniteQueryBehavior.mjs ***! | |
| 390 | + \*******************************************************************************/ | |
| 90 | 391 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 91 | 392 | |
| 92 | 393 | __webpack_require__.r(__webpack_exports__); |
| 93 | 394 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 395 | +/* harmony export */ getNextPageParam: function() { return /* binding */ getNextPageParam; }, | |
| 396 | +/* harmony export */ getPreviousPageParam: function() { return /* binding */ getPreviousPageParam; }, | |
| 94 | 397 | /* harmony export */ hasNextPage: function() { return /* binding */ hasNextPage; }, |
| 95 | 398 | /* harmony export */ hasPreviousPage: function() { return /* binding */ hasPreviousPage; }, |
| 96 | 399 | /* harmony export */ infiniteQueryBehavior: function() { return /* binding */ infiniteQueryBehavior; } |
| 97 | 400 | /* harmony export */ }); |
| 98 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 99 | -// src/infiniteQueryBehavior.ts | |
| 401 | +function infiniteQueryBehavior() { | |
| 402 | + return { | |
| 403 | + onFetch: context => { | |
| 404 | + context.fetchFn = () => { | |
| 405 | + var _context$fetchOptions, _context$fetchOptions2, _context$fetchOptions3, _context$fetchOptions4, _context$state$data, _context$state$data2; | |
| 100 | 406 | |
| 101 | -function infiniteQueryBehavior(pages) { | |
| 102 | - return { | |
| 103 | - onFetch: (context, query) => { | |
| 104 | - const options = context.options; | |
| 105 | - const direction = context.fetchOptions?.meta?.fetchMore?.direction; | |
| 106 | - const oldPages = context.state.data?.pages || []; | |
| 107 | - const oldPageParams = context.state.data?.pageParams || []; | |
| 108 | - let result = { pages: [], pageParams: [] }; | |
| 109 | - let currentPage = 0; | |
| 110 | - const fetchFn = async () => { | |
| 407 | + const refetchPage = (_context$fetchOptions = context.fetchOptions) == null ? void 0 : (_context$fetchOptions2 = _context$fetchOptions.meta) == null ? void 0 : _context$fetchOptions2.refetchPage; | |
| 408 | + const fetchMore = (_context$fetchOptions3 = context.fetchOptions) == null ? void 0 : (_context$fetchOptions4 = _context$fetchOptions3.meta) == null ? void 0 : _context$fetchOptions4.fetchMore; | |
| 409 | + const pageParam = fetchMore == null ? void 0 : fetchMore.pageParam; | |
| 410 | + const isFetchingNextPage = (fetchMore == null ? void 0 : fetchMore.direction) === 'forward'; | |
| 411 | + const isFetchingPreviousPage = (fetchMore == null ? void 0 : fetchMore.direction) === 'backward'; | |
| 412 | + const oldPages = ((_context$state$data = context.state.data) == null ? void 0 : _context$state$data.pages) || []; | |
| 413 | + const oldPageParams = ((_context$state$data2 = context.state.data) == null ? void 0 : _context$state$data2.pageParams) || []; | |
| 414 | + let newPageParams = oldPageParams; | |
| 111 | 415 | let cancelled = false; |
| 112 | - const addSignalProperty = (object) => { | |
| 113 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.addConsumeAwareSignal)( | |
| 114 | - object, | |
| 115 | - () => context.signal, | |
| 116 | - () => cancelled = true | |
| 117 | - ); | |
| 118 | - }; | |
| 119 | - const queryFn = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureQueryFn)(context.options, context.fetchOptions); | |
| 120 | - const fetchPage = async (data, param, previous) => { | |
| 416 | + | |
| 417 | + const addSignalProperty = object => { | |
| 418 | + Object.defineProperty(object, 'signal', { | |
| 419 | + enumerable: true, | |
| 420 | + get: () => { | |
| 421 | + var _context$signal; | |
| 422 | + | |
| 423 | + if ((_context$signal = context.signal) != null && _context$signal.aborted) { | |
| 424 | + cancelled = true; | |
| 425 | + } else { | |
| 426 | + var _context$signal2; | |
| 427 | + | |
| 428 | + (_context$signal2 = context.signal) == null ? void 0 : _context$signal2.addEventListener('abort', () => { | |
| 429 | + cancelled = true; | |
| 430 | + }); | |
| 431 | + } | |
| 432 | + | |
| 433 | + return context.signal; | |
| 434 | + } | |
| 435 | + }); | |
| 436 | + }; // Get query function | |
| 437 | + | |
| 438 | + | |
| 439 | + const queryFn = context.options.queryFn || (() => Promise.reject("Missing queryFn for queryKey '" + context.options.queryHash + "'")); | |
| 440 | + | |
| 441 | + const buildNewPages = (pages, param, page, previous) => { | |
| 442 | + newPageParams = previous ? [param, ...newPageParams] : [...newPageParams, param]; | |
| 443 | + return previous ? [page, ...pages] : [...pages, page]; | |
| 444 | + }; // Create function to fetch a page | |
| 445 | + | |
| 446 | + | |
| 447 | + const fetchPage = (pages, manual, param, previous) => { | |
| 121 | 448 | if (cancelled) { |
| 122 | - return Promise.reject(); | |
| 449 | + return Promise.reject('Cancelled'); | |
| 123 | 450 | } |
| 124 | - if (param == null && data.pages.length) { | |
| 125 | - return Promise.resolve(data); | |
| 451 | + | |
| 452 | + if (typeof param === 'undefined' && !manual && pages.length) { | |
| 453 | + return Promise.resolve(pages); | |
| 126 | 454 | } |
| 127 | - const createQueryFnContext = () => { | |
| 128 | - const queryFnContext2 = { | |
| 129 | - client: context.client, | |
| 130 | - queryKey: context.queryKey, | |
| 131 | - pageParam: param, | |
| 132 | - direction: previous ? "backward" : "forward", | |
| 133 | - meta: context.options.meta | |
| 134 | - }; | |
| 135 | - addSignalProperty(queryFnContext2); | |
| 136 | - return queryFnContext2; | |
| 455 | + | |
| 456 | + const queryFnContext = { | |
| 457 | + queryKey: context.queryKey, | |
| 458 | + pageParam: param, | |
| 459 | + meta: context.options.meta | |
| 137 | 460 | }; |
| 138 | - const queryFnContext = createQueryFnContext(); | |
| 139 | - const page = await queryFn(queryFnContext); | |
| 140 | - const { maxPages } = context.options; | |
| 141 | - const addTo = previous ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.addToStart : _utils_js__WEBPACK_IMPORTED_MODULE_0__.addToEnd; | |
| 142 | - return { | |
| 143 | - pages: addTo(data.pages, page, maxPages), | |
| 144 | - pageParams: addTo(data.pageParams, param, maxPages) | |
| 145 | - }; | |
| 461 | + addSignalProperty(queryFnContext); | |
| 462 | + const queryFnResult = queryFn(queryFnContext); | |
| 463 | + const promise = Promise.resolve(queryFnResult).then(page => buildNewPages(pages, param, page, previous)); | |
| 464 | + return promise; | |
| 146 | 465 | }; |
| 147 | - if (direction && oldPages.length) { | |
| 148 | - const previous = direction === "backward"; | |
| 149 | - const pageParamFn = previous ? getPreviousPageParam : getNextPageParam; | |
| 150 | - const oldData = { | |
| 151 | - pages: oldPages, | |
| 152 | - pageParams: oldPageParams | |
| 153 | - }; | |
| 154 | - const param = pageParamFn(options, oldData); | |
| 155 | - result = await fetchPage(oldData, param, previous); | |
| 156 | - } else { | |
| 157 | - const remainingPages = pages ?? oldPages.length; | |
| 158 | - do { | |
| 159 | - const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result); | |
| 160 | - if (currentPage > 0 && param == null) { | |
| 161 | - break; | |
| 162 | - } | |
| 163 | - result = await fetchPage(result, param); | |
| 164 | - currentPage++; | |
| 165 | - } while (currentPage < remainingPages); | |
| 466 | + | |
| 467 | + let promise; // Fetch first page? | |
| 468 | + | |
| 469 | + if (!oldPages.length) { | |
| 470 | + promise = fetchPage([]); | |
| 471 | + } // Fetch next page? | |
| 472 | + else if (isFetchingNextPage) { | |
| 473 | + const manual = typeof pageParam !== 'undefined'; | |
| 474 | + const param = manual ? pageParam : getNextPageParam(context.options, oldPages); | |
| 475 | + promise = fetchPage(oldPages, manual, param); | |
| 476 | + } // Fetch previous page? | |
| 477 | + else if (isFetchingPreviousPage) { | |
| 478 | + const manual = typeof pageParam !== 'undefined'; | |
| 479 | + const param = manual ? pageParam : getPreviousPageParam(context.options, oldPages); | |
| 480 | + promise = fetchPage(oldPages, manual, param, true); | |
| 481 | + } // Refetch pages | |
| 482 | + else { | |
| 483 | + newPageParams = []; | |
| 484 | + const manual = typeof context.options.getNextPageParam === 'undefined'; | |
| 485 | + const shouldFetchFirstPage = refetchPage && oldPages[0] ? refetchPage(oldPages[0], 0, oldPages) : true; // Fetch first page | |
| 486 | + | |
| 487 | + promise = shouldFetchFirstPage ? fetchPage([], manual, oldPageParams[0]) : Promise.resolve(buildNewPages([], oldPageParams[0], oldPages[0])); // Fetch remaining pages | |
| 488 | + | |
| 489 | + for (let i = 1; i < oldPages.length; i++) { | |
| 490 | + promise = promise.then(pages => { | |
| 491 | + const shouldFetchNextPage = refetchPage && oldPages[i] ? refetchPage(oldPages[i], i, oldPages) : true; | |
| 492 | + | |
| 493 | + if (shouldFetchNextPage) { | |
| 494 | + const param = manual ? oldPageParams[i] : getNextPageParam(context.options, pages); | |
| 495 | + return fetchPage(pages, manual, param); | |
| 496 | + } | |
| 497 | + | |
| 498 | + return Promise.resolve(buildNewPages(pages, oldPageParams[i], oldPages[i])); | |
| 499 | + }); | |
| 500 | + } | |
| 166 | 501 | } |
| 167 | - return result; | |
| 502 | + | |
| 503 | + const finalPromise = promise.then(pages => ({ | |
| 504 | + pages, | |
| 505 | + pageParams: newPageParams | |
| 506 | + })); | |
| 507 | + return finalPromise; | |
| 168 | 508 | }; |
| 169 | - if (context.options.persister) { | |
| 170 | - context.fetchFn = () => { | |
| 171 | - return context.options.persister?.( | |
| 172 | - fetchFn, | |
| 173 | - { | |
| 174 | - client: context.client, | |
| 175 | - queryKey: context.queryKey, | |
| 176 | - meta: context.options.meta, | |
| 177 | - signal: context.signal | |
| 178 | - }, | |
| 179 | - query | |
| 180 | - ); | |
| 181 | - }; | |
| 182 | - } else { | |
| 183 | - context.fetchFn = fetchFn; | |
| 184 | - } | |
| 185 | 509 | } |
| 186 | 510 | }; |
| 187 | 511 | } |
| 188 | -function getNextPageParam(options, { pages, pageParams }) { | |
| 189 | - const lastIndex = pages.length - 1; | |
| 190 | - return pages.length > 0 ? options.getNextPageParam( | |
| 191 | - pages[lastIndex], | |
| 192 | - pages, | |
| 193 | - pageParams[lastIndex], | |
| 194 | - pageParams | |
| 195 | - ) : void 0; | |
| 512 | +function getNextPageParam(options, pages) { | |
| 513 | + return options.getNextPageParam == null ? void 0 : options.getNextPageParam(pages[pages.length - 1], pages); | |
| 196 | 514 | } |
| 197 | -function getPreviousPageParam(options, { pages, pageParams }) { | |
| 198 | - return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0; | |
| 515 | +function getPreviousPageParam(options, pages) { | |
| 516 | + return options.getPreviousPageParam == null ? void 0 : options.getPreviousPageParam(pages[0], pages); | |
| 199 | 517 | } |
| 200 | -function hasNextPage(options, data) { | |
| 201 | - if (!data) return false; | |
| 202 | - return getNextPageParam(options, data) != null; | |
| 518 | +/** | |
| 519 | + * Checks if there is a next page. | |
| 520 | + * Returns `undefined` if it cannot be determined. | |
| 521 | + */ | |
| 522 | + | |
| 523 | +function hasNextPage(options, pages) { | |
| 524 | + if (options.getNextPageParam && Array.isArray(pages)) { | |
| 525 | + const nextPageParam = getNextPageParam(options, pages); | |
| 526 | + return typeof nextPageParam !== 'undefined' && nextPageParam !== null && nextPageParam !== false; | |
| 527 | + } | |
| 528 | + | |
| 529 | + return; | |
| 203 | 530 | } |
| 204 | -function hasPreviousPage(options, data) { | |
| 205 | - if (!data || !options.getPreviousPageParam) return false; | |
| 206 | - return getPreviousPageParam(options, data) != null; | |
| 531 | +/** | |
| 532 | + * Checks if there is a previous page. | |
| 533 | + * Returns `undefined` if it cannot be determined. | |
| 534 | + */ | |
| 535 | + | |
| 536 | +function hasPreviousPage(options, pages) { | |
| 537 | + if (options.getPreviousPageParam && Array.isArray(pages)) { | |
| 538 | + const previousPageParam = getPreviousPageParam(options, pages); | |
| 539 | + return typeof previousPageParam !== 'undefined' && previousPageParam !== null && previousPageParam !== false; | |
| 540 | + } | |
| 541 | + | |
| 542 | + return; | |
| 207 | 543 | } |
| 208 | 544 | |
| 209 | -//# sourceMappingURL=infiniteQueryBehavior.js.map | |
| 210 | 545 | |
| 546 | +//# sourceMappingURL=infiniteQueryBehavior.mjs.map | |
| 547 | + | |
| 548 | + | |
| 211 | 549 | /***/ }), |
| 212 | 550 | |
| 213 | -/***/ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js": | |
| 214 | -/*!*********************************************************************************!*\ | |
| 215 | - !*** ./node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js ***! | |
| 216 | - \*********************************************************************************/ | |
| 551 | +/***/ "./node_modules/@tanstack/query-core/build/lib/logger.mjs": | |
| 552 | +/*!****************************************************************!*\ | |
| 553 | + !*** ./node_modules/@tanstack/query-core/build/lib/logger.mjs ***! | |
| 554 | + \****************************************************************/ | |
| 217 | 555 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 218 | 556 | |
| 219 | 557 | __webpack_require__.r(__webpack_exports__); |
| 220 | 558 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 221 | -/* harmony export */ InfiniteQueryObserver: function() { return /* binding */ InfiniteQueryObserver; } | |
| 559 | +/* harmony export */ defaultLogger: function() { return /* binding */ defaultLogger; } | |
| 222 | 560 | /* harmony export */ }); |
| 223 | -/* harmony import */ var _queryObserver_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./queryObserver.js */ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js"); | |
| 224 | -/* harmony import */ var _infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./infiniteQueryBehavior.js */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js"); | |
| 225 | -// src/infiniteQueryObserver.ts | |
| 561 | +const defaultLogger = console; | |
| 226 | 562 | |
| 227 | 563 | |
| 228 | -var InfiniteQueryObserver = class extends _queryObserver_js__WEBPACK_IMPORTED_MODULE_0__.QueryObserver { | |
| 229 | - constructor(client, options) { | |
| 230 | - super(client, options); | |
| 231 | - } | |
| 232 | - bindMethods() { | |
| 233 | - super.bindMethods(); | |
| 234 | - this.fetchNextPage = this.fetchNextPage.bind(this); | |
| 235 | - this.fetchPreviousPage = this.fetchPreviousPage.bind(this); | |
| 236 | - } | |
| 237 | - setOptions(options) { | |
| 238 | - super.setOptions({ | |
| 239 | - ...options, | |
| 240 | - behavior: (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.infiniteQueryBehavior)() | |
| 241 | - }); | |
| 242 | - } | |
| 243 | - getOptimisticResult(options) { | |
| 244 | - options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.infiniteQueryBehavior)(); | |
| 245 | - return super.getOptimisticResult(options); | |
| 246 | - } | |
| 247 | - fetchNextPage(options) { | |
| 248 | - return this.fetch({ | |
| 249 | - ...options, | |
| 250 | - meta: { | |
| 251 | - fetchMore: { direction: "forward" } | |
| 252 | - } | |
| 253 | - }); | |
| 254 | - } | |
| 255 | - fetchPreviousPage(options) { | |
| 256 | - return this.fetch({ | |
| 257 | - ...options, | |
| 258 | - meta: { | |
| 259 | - fetchMore: { direction: "backward" } | |
| 260 | - } | |
| 261 | - }); | |
| 262 | - } | |
| 263 | - createResult(query, options) { | |
| 264 | - const { state } = query; | |
| 265 | - const parentResult = super.createResult(query, options); | |
| 266 | - const { isFetching, isRefetching, isError, isRefetchError } = parentResult; | |
| 267 | - const fetchDirection = state.fetchMeta?.fetchMore?.direction; | |
| 268 | - const isFetchNextPageError = isError && fetchDirection === "forward"; | |
| 269 | - const isFetchingNextPage = isFetching && fetchDirection === "forward"; | |
| 270 | - const isFetchPreviousPageError = isError && fetchDirection === "backward"; | |
| 271 | - const isFetchingPreviousPage = isFetching && fetchDirection === "backward"; | |
| 272 | - const result = { | |
| 273 | - ...parentResult, | |
| 274 | - fetchNextPage: this.fetchNextPage, | |
| 275 | - fetchPreviousPage: this.fetchPreviousPage, | |
| 276 | - hasNextPage: (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.hasNextPage)(options, state.data), | |
| 277 | - hasPreviousPage: (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.hasPreviousPage)(options, state.data), | |
| 278 | - isFetchNextPageError, | |
| 279 | - isFetchingNextPage, | |
| 280 | - isFetchPreviousPageError, | |
| 281 | - isFetchingPreviousPage, | |
| 282 | - isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError, | |
| 283 | - isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage | |
| 284 | - }; | |
| 285 | - return result; | |
| 286 | - } | |
| 287 | -}; | |
| 564 | +//# sourceMappingURL=logger.mjs.map | |
| 288 | 565 | |
| 289 | -//# sourceMappingURL=infiniteQueryObserver.js.map | |
| 290 | 566 | |
| 291 | 567 | /***/ }), |
| 292 | 568 | |
| 293 | -/***/ "./node_modules/@tanstack/query-core/build/modern/mutation.js": | |
| 294 | -/*!********************************************************************!*\ | |
| 295 | - !*** ./node_modules/@tanstack/query-core/build/modern/mutation.js ***! | |
| 296 | - \********************************************************************/ | |
| 569 | +/***/ "./node_modules/@tanstack/query-core/build/lib/mutation.mjs": | |
| 570 | +/*!******************************************************************!*\ | |
| 571 | + !*** ./node_modules/@tanstack/query-core/build/lib/mutation.mjs ***! | |
| 572 | + \******************************************************************/ | |
| 297 | 573 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 298 | 574 | |
| 299 | 575 | __webpack_require__.r(__webpack_exports__); |
| 300 | 576 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -300,281 +576,281 @@ | ||
| 300 | 576 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 301 | 577 | /* harmony export */ Mutation: function() { return /* binding */ Mutation; }, |
| 302 | 578 | /* harmony export */ getDefaultState: function() { return /* binding */ getDefaultState; } |
| 303 | 579 | /* harmony export */ }); |
| 304 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 305 | -/* harmony import */ var _removable_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./removable.js */ "./node_modules/@tanstack/query-core/build/modern/removable.js"); | |
| 306 | -/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); | |
| 307 | -// src/mutation.ts | |
| 580 | +/* harmony import */ var _logger_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger.mjs */ "./node_modules/@tanstack/query-core/build/lib/logger.mjs"); | |
| 581 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 582 | +/* harmony import */ var _removable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./removable.mjs */ "./node_modules/@tanstack/query-core/build/lib/removable.mjs"); | |
| 583 | +/* harmony import */ var _retryer_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer.mjs */ "./node_modules/@tanstack/query-core/build/lib/retryer.mjs"); | |
| 308 | 584 | |
| 309 | 585 | |
| 310 | 586 | |
| 311 | -var Mutation = class extends _removable_js__WEBPACK_IMPORTED_MODULE_1__.Removable { | |
| 312 | - #client; | |
| 313 | - #observers; | |
| 314 | - #mutationCache; | |
| 315 | - #retryer; | |
| 587 | + | |
| 588 | + | |
| 589 | +// CLASS | |
| 590 | +class Mutation extends _removable_mjs__WEBPACK_IMPORTED_MODULE_0__.Removable { | |
| 316 | 591 | constructor(config) { |
| 317 | 592 | super(); |
| 318 | - this.#client = config.client; | |
| 593 | + this.defaultOptions = config.defaultOptions; | |
| 319 | 594 | this.mutationId = config.mutationId; |
| 320 | - this.#mutationCache = config.mutationCache; | |
| 321 | - this.#observers = []; | |
| 595 | + this.mutationCache = config.mutationCache; | |
| 596 | + this.logger = config.logger || _logger_mjs__WEBPACK_IMPORTED_MODULE_1__.defaultLogger; | |
| 597 | + this.observers = []; | |
| 322 | 598 | this.state = config.state || getDefaultState(); |
| 323 | 599 | this.setOptions(config.options); |
| 324 | 600 | this.scheduleGc(); |
| 325 | 601 | } |
| 602 | + | |
| 326 | 603 | setOptions(options) { |
| 327 | - this.options = options; | |
| 328 | - this.updateGcTime(this.options.gcTime); | |
| 604 | + this.options = { ...this.defaultOptions, | |
| 605 | + ...options | |
| 606 | + }; | |
| 607 | + this.updateCacheTime(this.options.cacheTime); | |
| 329 | 608 | } |
| 609 | + | |
| 330 | 610 | get meta() { |
| 331 | 611 | return this.options.meta; |
| 332 | 612 | } |
| 613 | + | |
| 614 | + setState(state) { | |
| 615 | + this.dispatch({ | |
| 616 | + type: 'setState', | |
| 617 | + state | |
| 618 | + }); | |
| 619 | + } | |
| 620 | + | |
| 333 | 621 | addObserver(observer) { |
| 334 | - if (!this.#observers.includes(observer)) { | |
| 335 | - this.#observers.push(observer); | |
| 622 | + if (!this.observers.includes(observer)) { | |
| 623 | + this.observers.push(observer); // Stop the mutation from being garbage collected | |
| 624 | + | |
| 336 | 625 | this.clearGcTimeout(); |
| 337 | - this.#mutationCache.notify({ | |
| 338 | - type: "observerAdded", | |
| 626 | + this.mutationCache.notify({ | |
| 627 | + type: 'observerAdded', | |
| 339 | 628 | mutation: this, |
| 340 | 629 | observer |
| 341 | 630 | }); |
| 342 | 631 | } |
| 343 | 632 | } |
| 633 | + | |
| 344 | 634 | removeObserver(observer) { |
| 345 | - this.#observers = this.#observers.filter((x) => x !== observer); | |
| 635 | + this.observers = this.observers.filter(x => x !== observer); | |
| 346 | 636 | this.scheduleGc(); |
| 347 | - this.#mutationCache.notify({ | |
| 348 | - type: "observerRemoved", | |
| 637 | + this.mutationCache.notify({ | |
| 638 | + type: 'observerRemoved', | |
| 349 | 639 | mutation: this, |
| 350 | 640 | observer |
| 351 | 641 | }); |
| 352 | 642 | } |
| 643 | + | |
| 353 | 644 | optionalRemove() { |
| 354 | - if (!this.#observers.length) { | |
| 355 | - if (this.state.status === "pending") { | |
| 645 | + if (!this.observers.length) { | |
| 646 | + if (this.state.status === 'loading') { | |
| 356 | 647 | this.scheduleGc(); |
| 357 | 648 | } else { |
| 358 | - this.#mutationCache.remove(this); | |
| 649 | + this.mutationCache.remove(this); | |
| 359 | 650 | } |
| 360 | 651 | } |
| 361 | 652 | } |
| 653 | + | |
| 362 | 654 | continue() { |
| 363 | - return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before | |
| 364 | - this.execute(this.state.variables); | |
| 655 | + var _this$retryer$continu, _this$retryer; | |
| 656 | + | |
| 657 | + return (_this$retryer$continu = (_this$retryer = this.retryer) == null ? void 0 : _this$retryer.continue()) != null ? _this$retryer$continu : this.execute(); | |
| 365 | 658 | } |
| 366 | - async execute(variables) { | |
| 367 | - const onContinue = () => { | |
| 368 | - this.#dispatch({ type: "continue" }); | |
| 659 | + | |
| 660 | + async execute() { | |
| 661 | + const executeMutation = () => { | |
| 662 | + var _this$options$retry; | |
| 663 | + | |
| 664 | + this.retryer = (0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_2__.createRetryer)({ | |
| 665 | + fn: () => { | |
| 666 | + if (!this.options.mutationFn) { | |
| 667 | + return Promise.reject('No mutationFn found'); | |
| 668 | + } | |
| 669 | + | |
| 670 | + return this.options.mutationFn(this.state.variables); | |
| 671 | + }, | |
| 672 | + onFail: (failureCount, error) => { | |
| 673 | + this.dispatch({ | |
| 674 | + type: 'failed', | |
| 675 | + failureCount, | |
| 676 | + error | |
| 677 | + }); | |
| 678 | + }, | |
| 679 | + onPause: () => { | |
| 680 | + this.dispatch({ | |
| 681 | + type: 'pause' | |
| 682 | + }); | |
| 683 | + }, | |
| 684 | + onContinue: () => { | |
| 685 | + this.dispatch({ | |
| 686 | + type: 'continue' | |
| 687 | + }); | |
| 688 | + }, | |
| 689 | + retry: (_this$options$retry = this.options.retry) != null ? _this$options$retry : 0, | |
| 690 | + retryDelay: this.options.retryDelay, | |
| 691 | + networkMode: this.options.networkMode | |
| 692 | + }); | |
| 693 | + return this.retryer.promise; | |
| 369 | 694 | }; |
| 370 | - const mutationFnContext = { | |
| 371 | - client: this.#client, | |
| 372 | - meta: this.options.meta, | |
| 373 | - mutationKey: this.options.mutationKey | |
| 374 | - }; | |
| 375 | - this.#retryer = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.createRetryer)({ | |
| 376 | - fn: () => { | |
| 377 | - if (!this.options.mutationFn) { | |
| 378 | - return Promise.reject(new Error("No mutationFn found")); | |
| 379 | - } | |
| 380 | - return this.options.mutationFn(variables, mutationFnContext); | |
| 381 | - }, | |
| 382 | - onFail: (failureCount, error) => { | |
| 383 | - this.#dispatch({ type: "failed", failureCount, error }); | |
| 384 | - }, | |
| 385 | - onPause: () => { | |
| 386 | - this.#dispatch({ type: "pause" }); | |
| 387 | - }, | |
| 388 | - onContinue, | |
| 389 | - retry: this.options.retry ?? 0, | |
| 390 | - retryDelay: this.options.retryDelay, | |
| 391 | - networkMode: this.options.networkMode, | |
| 392 | - canRun: () => this.#mutationCache.canRun(this) | |
| 393 | - }); | |
| 394 | - const restored = this.state.status === "pending"; | |
| 395 | - const isPaused = !this.#retryer.canStart(); | |
| 695 | + | |
| 696 | + const restored = this.state.status === 'loading'; | |
| 697 | + | |
| 396 | 698 | try { |
| 397 | - if (restored) { | |
| 398 | - onContinue(); | |
| 399 | - } else { | |
| 400 | - this.#dispatch({ type: "pending", variables, isPaused }); | |
| 401 | - await this.#mutationCache.config.onMutate?.( | |
| 402 | - variables, | |
| 403 | - this, | |
| 404 | - mutationFnContext | |
| 405 | - ); | |
| 406 | - const context = await this.options.onMutate?.( | |
| 407 | - variables, | |
| 408 | - mutationFnContext | |
| 409 | - ); | |
| 699 | + var _this$mutationCache$c3, _this$mutationCache$c4, _this$options$onSucce, _this$options2, _this$mutationCache$c5, _this$mutationCache$c6, _this$options$onSettl, _this$options3; | |
| 700 | + | |
| 701 | + if (!restored) { | |
| 702 | + var _this$mutationCache$c, _this$mutationCache$c2, _this$options$onMutat, _this$options; | |
| 703 | + | |
| 704 | + this.dispatch({ | |
| 705 | + type: 'loading', | |
| 706 | + variables: this.options.variables | |
| 707 | + }); // Notify cache callback | |
| 708 | + | |
| 709 | + await ((_this$mutationCache$c = (_this$mutationCache$c2 = this.mutationCache.config).onMutate) == null ? void 0 : _this$mutationCache$c.call(_this$mutationCache$c2, this.state.variables, this)); | |
| 710 | + const context = await ((_this$options$onMutat = (_this$options = this.options).onMutate) == null ? void 0 : _this$options$onMutat.call(_this$options, this.state.variables)); | |
| 711 | + | |
| 410 | 712 | if (context !== this.state.context) { |
| 411 | - this.#dispatch({ | |
| 412 | - type: "pending", | |
| 713 | + this.dispatch({ | |
| 714 | + type: 'loading', | |
| 413 | 715 | context, |
| 414 | - variables, | |
| 415 | - isPaused | |
| 716 | + variables: this.state.variables | |
| 416 | 717 | }); |
| 417 | 718 | } |
| 418 | 719 | } |
| 419 | - const data = await this.#retryer.start(); | |
| 420 | - await this.#mutationCache.config.onSuccess?.( | |
| 421 | - data, | |
| 422 | - variables, | |
| 423 | - this.state.context, | |
| 424 | - this, | |
| 425 | - mutationFnContext | |
| 426 | - ); | |
| 427 | - await this.options.onSuccess?.( | |
| 428 | - data, | |
| 429 | - variables, | |
| 430 | - this.state.context, | |
| 431 | - mutationFnContext | |
| 432 | - ); | |
| 433 | - await this.#mutationCache.config.onSettled?.( | |
| 434 | - data, | |
| 435 | - null, | |
| 436 | - this.state.variables, | |
| 437 | - this.state.context, | |
| 438 | - this, | |
| 439 | - mutationFnContext | |
| 440 | - ); | |
| 441 | - await this.options.onSettled?.( | |
| 442 | - data, | |
| 443 | - null, | |
| 444 | - variables, | |
| 445 | - this.state.context, | |
| 446 | - mutationFnContext | |
| 447 | - ); | |
| 448 | - this.#dispatch({ type: "success", data }); | |
| 720 | + | |
| 721 | + const data = await executeMutation(); // Notify cache callback | |
| 722 | + | |
| 723 | + await ((_this$mutationCache$c3 = (_this$mutationCache$c4 = this.mutationCache.config).onSuccess) == null ? void 0 : _this$mutationCache$c3.call(_this$mutationCache$c4, data, this.state.variables, this.state.context, this)); | |
| 724 | + await ((_this$options$onSucce = (_this$options2 = this.options).onSuccess) == null ? void 0 : _this$options$onSucce.call(_this$options2, data, this.state.variables, this.state.context)); // Notify cache callback | |
| 725 | + | |
| 726 | + await ((_this$mutationCache$c5 = (_this$mutationCache$c6 = this.mutationCache.config).onSettled) == null ? void 0 : _this$mutationCache$c5.call(_this$mutationCache$c6, data, null, this.state.variables, this.state.context, this)); | |
| 727 | + await ((_this$options$onSettl = (_this$options3 = this.options).onSettled) == null ? void 0 : _this$options$onSettl.call(_this$options3, data, null, this.state.variables, this.state.context)); | |
| 728 | + this.dispatch({ | |
| 729 | + type: 'success', | |
| 730 | + data | |
| 731 | + }); | |
| 449 | 732 | return data; |
| 450 | 733 | } catch (error) { |
| 451 | 734 | try { |
| 452 | - await this.#mutationCache.config.onError?.( | |
| 453 | - error, | |
| 454 | - variables, | |
| 455 | - this.state.context, | |
| 456 | - this, | |
| 457 | - mutationFnContext | |
| 458 | - ); | |
| 459 | - await this.options.onError?.( | |
| 460 | - error, | |
| 461 | - variables, | |
| 462 | - this.state.context, | |
| 463 | - mutationFnContext | |
| 464 | - ); | |
| 465 | - await this.#mutationCache.config.onSettled?.( | |
| 466 | - void 0, | |
| 467 | - error, | |
| 468 | - this.state.variables, | |
| 469 | - this.state.context, | |
| 470 | - this, | |
| 471 | - mutationFnContext | |
| 472 | - ); | |
| 473 | - await this.options.onSettled?.( | |
| 474 | - void 0, | |
| 475 | - error, | |
| 476 | - variables, | |
| 477 | - this.state.context, | |
| 478 | - mutationFnContext | |
| 479 | - ); | |
| 735 | + var _this$mutationCache$c7, _this$mutationCache$c8, _this$options$onError, _this$options4, _this$mutationCache$c9, _this$mutationCache$c10, _this$options$onSettl2, _this$options5; | |
| 736 | + | |
| 737 | + // Notify cache callback | |
| 738 | + await ((_this$mutationCache$c7 = (_this$mutationCache$c8 = this.mutationCache.config).onError) == null ? void 0 : _this$mutationCache$c7.call(_this$mutationCache$c8, error, this.state.variables, this.state.context, this)); | |
| 739 | + | |
| 740 | + if (true) { | |
| 741 | + this.logger.error(error); | |
| 742 | + } | |
| 743 | + | |
| 744 | + await ((_this$options$onError = (_this$options4 = this.options).onError) == null ? void 0 : _this$options$onError.call(_this$options4, error, this.state.variables, this.state.context)); // Notify cache callback | |
| 745 | + | |
| 746 | + await ((_this$mutationCache$c9 = (_this$mutationCache$c10 = this.mutationCache.config).onSettled) == null ? void 0 : _this$mutationCache$c9.call(_this$mutationCache$c10, undefined, error, this.state.variables, this.state.context, this)); | |
| 747 | + await ((_this$options$onSettl2 = (_this$options5 = this.options).onSettled) == null ? void 0 : _this$options$onSettl2.call(_this$options5, undefined, error, this.state.variables, this.state.context)); | |
| 480 | 748 | throw error; |
| 481 | 749 | } finally { |
| 482 | - this.#dispatch({ type: "error", error }); | |
| 750 | + this.dispatch({ | |
| 751 | + type: 'error', | |
| 752 | + error: error | |
| 753 | + }); | |
| 483 | 754 | } |
| 484 | - } finally { | |
| 485 | - this.#mutationCache.runNext(this); | |
| 486 | 755 | } |
| 487 | 756 | } |
| 488 | - #dispatch(action) { | |
| 489 | - const reducer = (state) => { | |
| 757 | + | |
| 758 | + dispatch(action) { | |
| 759 | + const reducer = state => { | |
| 490 | 760 | switch (action.type) { |
| 491 | - case "failed": | |
| 492 | - return { | |
| 493 | - ...state, | |
| 761 | + case 'failed': | |
| 762 | + return { ...state, | |
| 494 | 763 | failureCount: action.failureCount, |
| 495 | 764 | failureReason: action.error |
| 496 | 765 | }; |
| 497 | - case "pause": | |
| 498 | - return { | |
| 499 | - ...state, | |
| 766 | + | |
| 767 | + case 'pause': | |
| 768 | + return { ...state, | |
| 500 | 769 | isPaused: true |
| 501 | 770 | }; |
| 502 | - case "continue": | |
| 503 | - return { | |
| 504 | - ...state, | |
| 771 | + | |
| 772 | + case 'continue': | |
| 773 | + return { ...state, | |
| 505 | 774 | isPaused: false |
| 506 | 775 | }; |
| 507 | - case "pending": | |
| 508 | - return { | |
| 509 | - ...state, | |
| 776 | + | |
| 777 | + case 'loading': | |
| 778 | + return { ...state, | |
| 510 | 779 | context: action.context, |
| 511 | - data: void 0, | |
| 780 | + data: undefined, | |
| 512 | 781 | failureCount: 0, |
| 513 | 782 | failureReason: null, |
| 514 | 783 | error: null, |
| 515 | - isPaused: action.isPaused, | |
| 516 | - status: "pending", | |
| 517 | - variables: action.variables, | |
| 518 | - submittedAt: Date.now() | |
| 784 | + isPaused: !(0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_2__.canFetch)(this.options.networkMode), | |
| 785 | + status: 'loading', | |
| 786 | + variables: action.variables | |
| 519 | 787 | }; |
| 520 | - case "success": | |
| 521 | - return { | |
| 522 | - ...state, | |
| 788 | + | |
| 789 | + case 'success': | |
| 790 | + return { ...state, | |
| 523 | 791 | data: action.data, |
| 524 | 792 | failureCount: 0, |
| 525 | 793 | failureReason: null, |
| 526 | 794 | error: null, |
| 527 | - status: "success", | |
| 795 | + status: 'success', | |
| 528 | 796 | isPaused: false |
| 529 | 797 | }; |
| 530 | - case "error": | |
| 531 | - return { | |
| 532 | - ...state, | |
| 533 | - data: void 0, | |
| 798 | + | |
| 799 | + case 'error': | |
| 800 | + return { ...state, | |
| 801 | + data: undefined, | |
| 534 | 802 | error: action.error, |
| 535 | 803 | failureCount: state.failureCount + 1, |
| 536 | 804 | failureReason: action.error, |
| 537 | 805 | isPaused: false, |
| 538 | - status: "error" | |
| 806 | + status: 'error' | |
| 539 | 807 | }; |
| 808 | + | |
| 809 | + case 'setState': | |
| 810 | + return { ...state, | |
| 811 | + ...action.state | |
| 812 | + }; | |
| 540 | 813 | } |
| 541 | 814 | }; |
| 815 | + | |
| 542 | 816 | this.state = reducer(this.state); |
| 543 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch(() => { | |
| 544 | - this.#observers.forEach((observer) => { | |
| 817 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { | |
| 818 | + this.observers.forEach(observer => { | |
| 545 | 819 | observer.onMutationUpdate(action); |
| 546 | 820 | }); |
| 547 | - this.#mutationCache.notify({ | |
| 821 | + this.mutationCache.notify({ | |
| 548 | 822 | mutation: this, |
| 549 | - type: "updated", | |
| 823 | + type: 'updated', | |
| 550 | 824 | action |
| 551 | 825 | }); |
| 552 | 826 | }); |
| 553 | 827 | } |
| 554 | -}; | |
| 828 | + | |
| 829 | +} | |
| 555 | 830 | function getDefaultState() { |
| 556 | 831 | return { |
| 557 | - context: void 0, | |
| 558 | - data: void 0, | |
| 832 | + context: undefined, | |
| 833 | + data: undefined, | |
| 559 | 834 | error: null, |
| 560 | 835 | failureCount: 0, |
| 561 | 836 | failureReason: null, |
| 562 | 837 | isPaused: false, |
| 563 | - status: "idle", | |
| 564 | - variables: void 0, | |
| 565 | - submittedAt: 0 | |
| 838 | + status: 'idle', | |
| 839 | + variables: undefined | |
| 566 | 840 | }; |
| 567 | 841 | } |
| 568 | 842 | |
| 569 | -//# sourceMappingURL=mutation.js.map | |
| 570 | 843 | |
| 844 | +//# sourceMappingURL=mutation.mjs.map | |
| 845 | + | |
| 846 | + | |
| 571 | 847 | /***/ }), |
| 572 | 848 | |
| 573 | -/***/ "./node_modules/@tanstack/query-core/build/modern/mutationCache.js": | |
| 574 | -/*!*************************************************************************!*\ | |
| 575 | - !*** ./node_modules/@tanstack/query-core/build/modern/mutationCache.js ***! | |
| 576 | - \*************************************************************************/ | |
| 849 | +/***/ "./node_modules/@tanstack/query-core/build/lib/mutationCache.mjs": | |
| 850 | +/*!***********************************************************************!*\ | |
| 851 | + !*** ./node_modules/@tanstack/query-core/build/lib/mutationCache.mjs ***! | |
| 852 | + \***********************************************************************/ | |
| 577 | 853 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 578 | 854 | |
| 579 | 855 | __webpack_require__.r(__webpack_exports__); |
| 580 | 856 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -579,141 +855,113 @@ | ||
| 579 | 855 | __webpack_require__.r(__webpack_exports__); |
| 580 | 856 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 581 | 857 | /* harmony export */ MutationCache: function() { return /* binding */ MutationCache; } |
| 582 | 858 | /* harmony export */ }); |
| 583 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 584 | -/* harmony import */ var _mutation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutation.js */ "./node_modules/@tanstack/query-core/build/modern/mutation.js"); | |
| 585 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 586 | -/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); | |
| 587 | -// src/mutationCache.ts | |
| 859 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 860 | +/* harmony import */ var _mutation_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutation.mjs */ "./node_modules/@tanstack/query-core/build/lib/mutation.mjs"); | |
| 861 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 862 | +/* harmony import */ var _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.mjs */ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs"); | |
| 588 | 863 | |
| 589 | 864 | |
| 590 | 865 | |
| 591 | 866 | |
| 592 | -var MutationCache = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_3__.Subscribable { | |
| 593 | - constructor(config = {}) { | |
| 867 | + | |
| 868 | +// CLASS | |
| 869 | +class MutationCache extends _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 870 | + constructor(config) { | |
| 594 | 871 | super(); |
| 595 | - this.config = config; | |
| 596 | - this.#mutations = /* @__PURE__ */ new Set(); | |
| 597 | - this.#scopes = /* @__PURE__ */ new Map(); | |
| 598 | - this.#mutationId = 0; | |
| 872 | + this.config = config || {}; | |
| 873 | + this.mutations = []; | |
| 874 | + this.mutationId = 0; | |
| 599 | 875 | } |
| 600 | - #mutations; | |
| 601 | - #scopes; | |
| 602 | - #mutationId; | |
| 876 | + | |
| 603 | 877 | build(client, options, state) { |
| 604 | - const mutation = new _mutation_js__WEBPACK_IMPORTED_MODULE_1__.Mutation({ | |
| 605 | - client, | |
| 878 | + const mutation = new _mutation_mjs__WEBPACK_IMPORTED_MODULE_1__.Mutation({ | |
| 606 | 879 | mutationCache: this, |
| 607 | - mutationId: ++this.#mutationId, | |
| 880 | + logger: client.getLogger(), | |
| 881 | + mutationId: ++this.mutationId, | |
| 608 | 882 | options: client.defaultMutationOptions(options), |
| 609 | - state | |
| 883 | + state, | |
| 884 | + defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined | |
| 610 | 885 | }); |
| 611 | 886 | this.add(mutation); |
| 612 | 887 | return mutation; |
| 613 | 888 | } |
| 889 | + | |
| 614 | 890 | add(mutation) { |
| 615 | - this.#mutations.add(mutation); | |
| 616 | - const scope = scopeFor(mutation); | |
| 617 | - if (typeof scope === "string") { | |
| 618 | - const scopedMutations = this.#scopes.get(scope); | |
| 619 | - if (scopedMutations) { | |
| 620 | - scopedMutations.push(mutation); | |
| 621 | - } else { | |
| 622 | - this.#scopes.set(scope, [mutation]); | |
| 623 | - } | |
| 624 | - } | |
| 625 | - this.notify({ type: "added", mutation }); | |
| 891 | + this.mutations.push(mutation); | |
| 892 | + this.notify({ | |
| 893 | + type: 'added', | |
| 894 | + mutation | |
| 895 | + }); | |
| 626 | 896 | } |
| 897 | + | |
| 627 | 898 | remove(mutation) { |
| 628 | - if (this.#mutations.delete(mutation)) { | |
| 629 | - const scope = scopeFor(mutation); | |
| 630 | - if (typeof scope === "string") { | |
| 631 | - const scopedMutations = this.#scopes.get(scope); | |
| 632 | - if (scopedMutations) { | |
| 633 | - if (scopedMutations.length > 1) { | |
| 634 | - const index = scopedMutations.indexOf(mutation); | |
| 635 | - if (index !== -1) { | |
| 636 | - scopedMutations.splice(index, 1); | |
| 637 | - } | |
| 638 | - } else if (scopedMutations[0] === mutation) { | |
| 639 | - this.#scopes.delete(scope); | |
| 640 | - } | |
| 641 | - } | |
| 642 | - } | |
| 643 | - } | |
| 644 | - this.notify({ type: "removed", mutation }); | |
| 899 | + this.mutations = this.mutations.filter(x => x !== mutation); | |
| 900 | + this.notify({ | |
| 901 | + type: 'removed', | |
| 902 | + mutation | |
| 903 | + }); | |
| 645 | 904 | } |
| 646 | - canRun(mutation) { | |
| 647 | - const scope = scopeFor(mutation); | |
| 648 | - if (typeof scope === "string") { | |
| 649 | - const mutationsWithSameScope = this.#scopes.get(scope); | |
| 650 | - const firstPendingMutation = mutationsWithSameScope?.find( | |
| 651 | - (m) => m.state.status === "pending" | |
| 652 | - ); | |
| 653 | - return !firstPendingMutation || firstPendingMutation === mutation; | |
| 654 | - } else { | |
| 655 | - return true; | |
| 656 | - } | |
| 657 | - } | |
| 658 | - runNext(mutation) { | |
| 659 | - const scope = scopeFor(mutation); | |
| 660 | - if (typeof scope === "string") { | |
| 661 | - const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused); | |
| 662 | - return foundMutation?.continue() ?? Promise.resolve(); | |
| 663 | - } else { | |
| 664 | - return Promise.resolve(); | |
| 665 | - } | |
| 666 | - } | |
| 905 | + | |
| 667 | 906 | clear() { |
| 668 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch(() => { | |
| 669 | - this.#mutations.forEach((mutation) => { | |
| 670 | - this.notify({ type: "removed", mutation }); | |
| 907 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { | |
| 908 | + this.mutations.forEach(mutation => { | |
| 909 | + this.remove(mutation); | |
| 671 | 910 | }); |
| 672 | - this.#mutations.clear(); | |
| 673 | - this.#scopes.clear(); | |
| 674 | 911 | }); |
| 675 | 912 | } |
| 913 | + | |
| 676 | 914 | getAll() { |
| 677 | - return Array.from(this.#mutations); | |
| 915 | + return this.mutations; | |
| 678 | 916 | } |
| 917 | + | |
| 679 | 918 | find(filters) { |
| 680 | - const defaultedFilters = { exact: true, ...filters }; | |
| 681 | - return this.getAll().find( | |
| 682 | - (mutation) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.matchMutation)(defaultedFilters, mutation) | |
| 683 | - ); | |
| 919 | + if (typeof filters.exact === 'undefined') { | |
| 920 | + filters.exact = true; | |
| 921 | + } | |
| 922 | + | |
| 923 | + return this.mutations.find(mutation => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_3__.matchMutation)(filters, mutation)); | |
| 684 | 924 | } |
| 685 | - findAll(filters = {}) { | |
| 686 | - return this.getAll().filter((mutation) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.matchMutation)(filters, mutation)); | |
| 925 | + | |
| 926 | + findAll(filters) { | |
| 927 | + return this.mutations.filter(mutation => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_3__.matchMutation)(filters, mutation)); | |
| 687 | 928 | } |
| 929 | + | |
| 688 | 930 | notify(event) { |
| 689 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch(() => { | |
| 690 | - this.listeners.forEach((listener) => { | |
| 931 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { | |
| 932 | + this.listeners.forEach(({ | |
| 933 | + listener | |
| 934 | + }) => { | |
| 691 | 935 | listener(event); |
| 692 | 936 | }); |
| 693 | 937 | }); |
| 694 | 938 | } |
| 939 | + | |
| 695 | 940 | resumePausedMutations() { |
| 696 | - const pausedMutations = this.getAll().filter((x) => x.state.isPaused); | |
| 697 | - return _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch( | |
| 698 | - () => Promise.all( | |
| 699 | - pausedMutations.map((mutation) => mutation.continue().catch(_utils_js__WEBPACK_IMPORTED_MODULE_2__.noop)) | |
| 700 | - ) | |
| 701 | - ); | |
| 941 | + var _this$resuming; | |
| 942 | + | |
| 943 | + this.resuming = ((_this$resuming = this.resuming) != null ? _this$resuming : Promise.resolve()).then(() => { | |
| 944 | + const pausedMutations = this.mutations.filter(x => x.state.isPaused); | |
| 945 | + return _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => pausedMutations.reduce((promise, mutation) => promise.then(() => mutation.continue().catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_3__.noop)), Promise.resolve())); | |
| 946 | + }).then(() => { | |
| 947 | + this.resuming = undefined; | |
| 948 | + }); | |
| 949 | + return this.resuming; | |
| 702 | 950 | } |
| 703 | -}; | |
| 704 | -function scopeFor(mutation) { | |
| 705 | - return mutation.options.scope?.id; | |
| 951 | + | |
| 706 | 952 | } |
| 707 | 953 | |
| 708 | -//# sourceMappingURL=mutationCache.js.map | |
| 709 | 954 | |
| 955 | +//# sourceMappingURL=mutationCache.mjs.map | |
| 956 | + | |
| 957 | + | |
| 710 | 958 | /***/ }), |
| 711 | 959 | |
| 712 | -/***/ "./node_modules/@tanstack/query-core/build/modern/mutationObserver.js": | |
| 713 | -/*!****************************************************************************!*\ | |
| 714 | - !*** ./node_modules/@tanstack/query-core/build/modern/mutationObserver.js ***! | |
| 715 | - \****************************************************************************/ | |
| 960 | +/***/ "./node_modules/@tanstack/query-core/build/lib/mutationObserver.mjs": | |
| 961 | +/*!**************************************************************************!*\ | |
| 962 | + !*** ./node_modules/@tanstack/query-core/build/lib/mutationObserver.mjs ***! | |
| 963 | + \**************************************************************************/ | |
| 716 | 964 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 717 | 965 | |
| 718 | 966 | __webpack_require__.r(__webpack_exports__); |
| 719 | 967 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -718,179 +966,221 @@ | ||
| 718 | 966 | __webpack_require__.r(__webpack_exports__); |
| 719 | 967 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 720 | 968 | /* harmony export */ MutationObserver: function() { return /* binding */ MutationObserver; } |
| 721 | 969 | /* harmony export */ }); |
| 722 | -/* harmony import */ var _mutation_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mutation.js */ "./node_modules/@tanstack/query-core/build/modern/mutation.js"); | |
| 723 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 724 | -/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); | |
| 725 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 726 | -// src/mutationObserver.ts | |
| 970 | +/* harmony import */ var _mutation_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mutation.mjs */ "./node_modules/@tanstack/query-core/build/lib/mutation.mjs"); | |
| 971 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 972 | +/* harmony import */ var _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.mjs */ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs"); | |
| 973 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 727 | 974 | |
| 728 | 975 | |
| 729 | 976 | |
| 730 | 977 | |
| 731 | -var MutationObserver = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_2__.Subscribable { | |
| 732 | - #client; | |
| 733 | - #currentResult = void 0; | |
| 734 | - #currentMutation; | |
| 735 | - #mutateOptions; | |
| 978 | + | |
| 979 | +// CLASS | |
| 980 | +class MutationObserver extends _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 736 | 981 | constructor(client, options) { |
| 737 | 982 | super(); |
| 738 | - this.#client = client; | |
| 983 | + this.client = client; | |
| 739 | 984 | this.setOptions(options); |
| 740 | 985 | this.bindMethods(); |
| 741 | - this.#updateResult(); | |
| 986 | + this.updateResult(); | |
| 742 | 987 | } |
| 988 | + | |
| 743 | 989 | bindMethods() { |
| 744 | 990 | this.mutate = this.mutate.bind(this); |
| 745 | 991 | this.reset = this.reset.bind(this); |
| 746 | 992 | } |
| 993 | + | |
| 747 | 994 | setOptions(options) { |
| 995 | + var _this$currentMutation; | |
| 996 | + | |
| 748 | 997 | const prevOptions = this.options; |
| 749 | - this.options = this.#client.defaultMutationOptions(options); | |
| 750 | - if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.shallowEqualObjects)(this.options, prevOptions)) { | |
| 751 | - this.#client.getMutationCache().notify({ | |
| 752 | - type: "observerOptionsUpdated", | |
| 753 | - mutation: this.#currentMutation, | |
| 998 | + this.options = this.client.defaultMutationOptions(options); | |
| 999 | + | |
| 1000 | + if (!(0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(prevOptions, this.options)) { | |
| 1001 | + this.client.getMutationCache().notify({ | |
| 1002 | + type: 'observerOptionsUpdated', | |
| 1003 | + mutation: this.currentMutation, | |
| 754 | 1004 | observer: this |
| 755 | 1005 | }); |
| 756 | 1006 | } |
| 757 | - if (prevOptions?.mutationKey && this.options.mutationKey && (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.hashKey)(prevOptions.mutationKey) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.hashKey)(this.options.mutationKey)) { | |
| 758 | - this.reset(); | |
| 759 | - } else if (this.#currentMutation?.state.status === "pending") { | |
| 760 | - this.#currentMutation.setOptions(this.options); | |
| 761 | - } | |
| 1007 | + | |
| 1008 | + (_this$currentMutation = this.currentMutation) == null ? void 0 : _this$currentMutation.setOptions(this.options); | |
| 762 | 1009 | } |
| 1010 | + | |
| 763 | 1011 | onUnsubscribe() { |
| 764 | 1012 | if (!this.hasListeners()) { |
| 765 | - this.#currentMutation?.removeObserver(this); | |
| 1013 | + var _this$currentMutation2; | |
| 1014 | + | |
| 1015 | + (_this$currentMutation2 = this.currentMutation) == null ? void 0 : _this$currentMutation2.removeObserver(this); | |
| 766 | 1016 | } |
| 767 | 1017 | } |
| 1018 | + | |
| 768 | 1019 | onMutationUpdate(action) { |
| 769 | - this.#updateResult(); | |
| 770 | - this.#notify(action); | |
| 1020 | + this.updateResult(); // Determine which callbacks to trigger | |
| 1021 | + | |
| 1022 | + const notifyOptions = { | |
| 1023 | + listeners: true | |
| 1024 | + }; | |
| 1025 | + | |
| 1026 | + if (action.type === 'success') { | |
| 1027 | + notifyOptions.onSuccess = true; | |
| 1028 | + } else if (action.type === 'error') { | |
| 1029 | + notifyOptions.onError = true; | |
| 1030 | + } | |
| 1031 | + | |
| 1032 | + this.notify(notifyOptions); | |
| 771 | 1033 | } |
| 1034 | + | |
| 772 | 1035 | getCurrentResult() { |
| 773 | - return this.#currentResult; | |
| 1036 | + return this.currentResult; | |
| 774 | 1037 | } |
| 1038 | + | |
| 775 | 1039 | reset() { |
| 776 | - this.#currentMutation?.removeObserver(this); | |
| 777 | - this.#currentMutation = void 0; | |
| 778 | - this.#updateResult(); | |
| 779 | - this.#notify(); | |
| 1040 | + this.currentMutation = undefined; | |
| 1041 | + this.updateResult(); | |
| 1042 | + this.notify({ | |
| 1043 | + listeners: true | |
| 1044 | + }); | |
| 780 | 1045 | } |
| 1046 | + | |
| 781 | 1047 | mutate(variables, options) { |
| 782 | - this.#mutateOptions = options; | |
| 783 | - this.#currentMutation?.removeObserver(this); | |
| 784 | - this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options); | |
| 785 | - this.#currentMutation.addObserver(this); | |
| 786 | - return this.#currentMutation.execute(variables); | |
| 1048 | + this.mutateOptions = options; | |
| 1049 | + | |
| 1050 | + if (this.currentMutation) { | |
| 1051 | + this.currentMutation.removeObserver(this); | |
| 1052 | + } | |
| 1053 | + | |
| 1054 | + this.currentMutation = this.client.getMutationCache().build(this.client, { ...this.options, | |
| 1055 | + variables: typeof variables !== 'undefined' ? variables : this.options.variables | |
| 1056 | + }); | |
| 1057 | + this.currentMutation.addObserver(this); | |
| 1058 | + return this.currentMutation.execute(); | |
| 787 | 1059 | } |
| 788 | - #updateResult() { | |
| 789 | - const state = this.#currentMutation?.state ?? (0,_mutation_js__WEBPACK_IMPORTED_MODULE_0__.getDefaultState)(); | |
| 790 | - this.#currentResult = { | |
| 791 | - ...state, | |
| 792 | - isPending: state.status === "pending", | |
| 793 | - isSuccess: state.status === "success", | |
| 794 | - isError: state.status === "error", | |
| 795 | - isIdle: state.status === "idle", | |
| 1060 | + | |
| 1061 | + updateResult() { | |
| 1062 | + const state = this.currentMutation ? this.currentMutation.state : (0,_mutation_mjs__WEBPACK_IMPORTED_MODULE_2__.getDefaultState)(); | |
| 1063 | + const result = { ...state, | |
| 1064 | + isLoading: state.status === 'loading', | |
| 1065 | + isSuccess: state.status === 'success', | |
| 1066 | + isError: state.status === 'error', | |
| 1067 | + isIdle: state.status === 'idle', | |
| 796 | 1068 | mutate: this.mutate, |
| 797 | 1069 | reset: this.reset |
| 798 | 1070 | }; |
| 1071 | + this.currentResult = result; | |
| 799 | 1072 | } |
| 800 | - #notify(action) { | |
| 801 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batch(() => { | |
| 802 | - if (this.#mutateOptions && this.hasListeners()) { | |
| 803 | - const variables = this.#currentResult.variables; | |
| 804 | - const onMutateResult = this.#currentResult.context; | |
| 805 | - const context = { | |
| 806 | - client: this.#client, | |
| 807 | - meta: this.options.meta, | |
| 808 | - mutationKey: this.options.mutationKey | |
| 809 | - }; | |
| 810 | - if (action?.type === "success") { | |
| 811 | - this.#mutateOptions.onSuccess?.( | |
| 812 | - action.data, | |
| 813 | - variables, | |
| 814 | - onMutateResult, | |
| 815 | - context | |
| 816 | - ); | |
| 817 | - this.#mutateOptions.onSettled?.( | |
| 818 | - action.data, | |
| 819 | - null, | |
| 820 | - variables, | |
| 821 | - onMutateResult, | |
| 822 | - context | |
| 823 | - ); | |
| 824 | - } else if (action?.type === "error") { | |
| 825 | - this.#mutateOptions.onError?.( | |
| 826 | - action.error, | |
| 827 | - variables, | |
| 828 | - onMutateResult, | |
| 829 | - context | |
| 830 | - ); | |
| 831 | - this.#mutateOptions.onSettled?.( | |
| 832 | - void 0, | |
| 833 | - action.error, | |
| 834 | - variables, | |
| 835 | - onMutateResult, | |
| 836 | - context | |
| 837 | - ); | |
| 1073 | + | |
| 1074 | + notify(options) { | |
| 1075 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { | |
| 1076 | + // First trigger the mutate callbacks | |
| 1077 | + if (this.mutateOptions && this.hasListeners()) { | |
| 1078 | + if (options.onSuccess) { | |
| 1079 | + var _this$mutateOptions$o, _this$mutateOptions, _this$mutateOptions$o2, _this$mutateOptions2; | |
| 1080 | + | |
| 1081 | + (_this$mutateOptions$o = (_this$mutateOptions = this.mutateOptions).onSuccess) == null ? void 0 : _this$mutateOptions$o.call(_this$mutateOptions, this.currentResult.data, this.currentResult.variables, this.currentResult.context); | |
| 1082 | + (_this$mutateOptions$o2 = (_this$mutateOptions2 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o2.call(_this$mutateOptions2, this.currentResult.data, null, this.currentResult.variables, this.currentResult.context); | |
| 1083 | + } else if (options.onError) { | |
| 1084 | + var _this$mutateOptions$o3, _this$mutateOptions3, _this$mutateOptions$o4, _this$mutateOptions4; | |
| 1085 | + | |
| 1086 | + (_this$mutateOptions$o3 = (_this$mutateOptions3 = this.mutateOptions).onError) == null ? void 0 : _this$mutateOptions$o3.call(_this$mutateOptions3, this.currentResult.error, this.currentResult.variables, this.currentResult.context); | |
| 1087 | + (_this$mutateOptions$o4 = (_this$mutateOptions4 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o4.call(_this$mutateOptions4, undefined, this.currentResult.error, this.currentResult.variables, this.currentResult.context); | |
| 838 | 1088 | } |
| 1089 | + } // Then trigger the listeners | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + if (options.listeners) { | |
| 1093 | + this.listeners.forEach(({ | |
| 1094 | + listener | |
| 1095 | + }) => { | |
| 1096 | + listener(this.currentResult); | |
| 1097 | + }); | |
| 839 | 1098 | } |
| 840 | - this.listeners.forEach((listener) => { | |
| 841 | - listener(this.#currentResult); | |
| 842 | - }); | |
| 843 | 1099 | }); |
| 844 | 1100 | } |
| 845 | -}; | |
| 846 | 1101 | |
| 847 | -//# sourceMappingURL=mutationObserver.js.map | |
| 1102 | +} | |
| 848 | 1103 | |
| 1104 | + | |
| 1105 | +//# sourceMappingURL=mutationObserver.mjs.map | |
| 1106 | + | |
| 1107 | + | |
| 849 | 1108 | /***/ }), |
| 850 | 1109 | |
| 851 | -/***/ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js": | |
| 852 | -/*!*************************************************************************!*\ | |
| 853 | - !*** ./node_modules/@tanstack/query-core/build/modern/notifyManager.js ***! | |
| 854 | - \*************************************************************************/ | |
| 1110 | +/***/ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs": | |
| 1111 | +/*!***********************************************************************!*\ | |
| 1112 | + !*** ./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs ***! | |
| 1113 | + \***********************************************************************/ | |
| 855 | 1114 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 856 | 1115 | |
| 857 | 1116 | __webpack_require__.r(__webpack_exports__); |
| 858 | 1117 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 859 | 1118 | /* harmony export */ createNotifyManager: function() { return /* binding */ createNotifyManager; }, |
| 860 | -/* harmony export */ defaultScheduler: function() { return /* binding */ defaultScheduler; }, | |
| 861 | 1119 | /* harmony export */ notifyManager: function() { return /* binding */ notifyManager; } |
| 862 | 1120 | /* harmony export */ }); |
| 863 | -/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); | |
| 864 | -// src/notifyManager.ts | |
| 1121 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 865 | 1122 | |
| 866 | -var defaultScheduler = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.systemSetTimeoutZero; | |
| 1123 | + | |
| 867 | 1124 | function createNotifyManager() { |
| 868 | 1125 | let queue = []; |
| 869 | 1126 | let transactions = 0; |
| 870 | - let notifyFn = (callback) => { | |
| 1127 | + | |
| 1128 | + let notifyFn = callback => { | |
| 871 | 1129 | callback(); |
| 872 | 1130 | }; |
| 873 | - let batchNotifyFn = (callback) => { | |
| 1131 | + | |
| 1132 | + let batchNotifyFn = callback => { | |
| 874 | 1133 | callback(); |
| 875 | 1134 | }; |
| 876 | - let scheduleFn = defaultScheduler; | |
| 877 | - const schedule = (callback) => { | |
| 1135 | + | |
| 1136 | + const batch = callback => { | |
| 1137 | + let result; | |
| 1138 | + transactions++; | |
| 1139 | + | |
| 1140 | + try { | |
| 1141 | + result = callback(); | |
| 1142 | + } finally { | |
| 1143 | + transactions--; | |
| 1144 | + | |
| 1145 | + if (!transactions) { | |
| 1146 | + flush(); | |
| 1147 | + } | |
| 1148 | + } | |
| 1149 | + | |
| 1150 | + return result; | |
| 1151 | + }; | |
| 1152 | + | |
| 1153 | + const schedule = callback => { | |
| 878 | 1154 | if (transactions) { |
| 879 | 1155 | queue.push(callback); |
| 880 | 1156 | } else { |
| 881 | - scheduleFn(() => { | |
| 1157 | + (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_0__.scheduleMicrotask)(() => { | |
| 882 | 1158 | notifyFn(callback); |
| 883 | 1159 | }); |
| 884 | 1160 | } |
| 885 | 1161 | }; |
| 1162 | + /** | |
| 1163 | + * All calls to the wrapped function will be batched. | |
| 1164 | + */ | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + const batchCalls = callback => { | |
| 1168 | + return (...args) => { | |
| 1169 | + schedule(() => { | |
| 1170 | + callback(...args); | |
| 1171 | + }); | |
| 1172 | + }; | |
| 1173 | + }; | |
| 1174 | + | |
| 886 | 1175 | const flush = () => { |
| 887 | 1176 | const originalQueue = queue; |
| 888 | 1177 | queue = []; |
| 1178 | + | |
| 889 | 1179 | if (originalQueue.length) { |
| 890 | - scheduleFn(() => { | |
| 1180 | + (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_0__.scheduleMicrotask)(() => { | |
| 891 | 1181 | batchNotifyFn(() => { |
| 892 | - originalQueue.forEach((callback) => { | |
| 1182 | + originalQueue.forEach(callback => { | |
| 893 | 1183 | notifyFn(callback); |
| 894 | 1184 | }); |
| 895 | 1185 | }); |
| 896 | 1186 | }); |
| @@ -895,62 +1185,48 @@ | ||
| 895 | 1185 | }); |
| 896 | 1186 | }); |
| 897 | 1187 | } |
| 898 | 1188 | }; |
| 1189 | + /** | |
| 1190 | + * Use this method to set a custom notify function. | |
| 1191 | + * This can be used to for example wrap notifications with `React.act` while running tests. | |
| 1192 | + */ | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + const setNotifyFunction = fn => { | |
| 1196 | + notifyFn = fn; | |
| 1197 | + }; | |
| 1198 | + /** | |
| 1199 | + * Use this method to set a custom function to batch notifications together into a single tick. | |
| 1200 | + * By default React Query will use the batch function provided by ReactDOM or React Native. | |
| 1201 | + */ | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + const setBatchNotifyFunction = fn => { | |
| 1205 | + batchNotifyFn = fn; | |
| 1206 | + }; | |
| 1207 | + | |
| 899 | 1208 | return { |
| 900 | - batch: (callback) => { | |
| 901 | - let result; | |
| 902 | - transactions++; | |
| 903 | - try { | |
| 904 | - result = callback(); | |
| 905 | - } finally { | |
| 906 | - transactions--; | |
| 907 | - if (!transactions) { | |
| 908 | - flush(); | |
| 909 | - } | |
| 910 | - } | |
| 911 | - return result; | |
| 912 | - }, | |
| 913 | - /** | |
| 914 | - * All calls to the wrapped function will be batched. | |
| 915 | - */ | |
| 916 | - batchCalls: (callback) => { | |
| 917 | - return (...args) => { | |
| 918 | - schedule(() => { | |
| 919 | - callback(...args); | |
| 920 | - }); | |
| 921 | - }; | |
| 922 | - }, | |
| 1209 | + batch, | |
| 1210 | + batchCalls, | |
| 923 | 1211 | schedule, |
| 924 | - /** | |
| 925 | - * Use this method to set a custom notify function. | |
| 926 | - * This can be used to for example wrap notifications with `React.act` while running tests. | |
| 927 | - */ | |
| 928 | - setNotifyFunction: (fn) => { | |
| 929 | - notifyFn = fn; | |
| 930 | - }, | |
| 931 | - /** | |
| 932 | - * Use this method to set a custom function to batch notifications together into a single tick. | |
| 933 | - * By default React Query will use the batch function provided by ReactDOM or React Native. | |
| 934 | - */ | |
| 935 | - setBatchNotifyFunction: (fn) => { | |
| 936 | - batchNotifyFn = fn; | |
| 937 | - }, | |
| 938 | - setScheduler: (fn) => { | |
| 939 | - scheduleFn = fn; | |
| 940 | - } | |
| 1212 | + setNotifyFunction, | |
| 1213 | + setBatchNotifyFunction | |
| 941 | 1214 | }; |
| 942 | -} | |
| 943 | -var notifyManager = createNotifyManager(); | |
| 1215 | +} // SINGLETON | |
| 944 | 1216 | |
| 945 | -//# sourceMappingURL=notifyManager.js.map | |
| 1217 | +const notifyManager = createNotifyManager(); | |
| 946 | 1218 | |
| 1219 | + | |
| 1220 | +//# sourceMappingURL=notifyManager.mjs.map | |
| 1221 | + | |
| 1222 | + | |
| 947 | 1223 | /***/ }), |
| 948 | 1224 | |
| 949 | -/***/ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js": | |
| 950 | -/*!*************************************************************************!*\ | |
| 951 | - !*** ./node_modules/@tanstack/query-core/build/modern/onlineManager.js ***! | |
| 952 | - \*************************************************************************/ | |
| 1225 | +/***/ "./node_modules/@tanstack/query-core/build/lib/onlineManager.mjs": | |
| 1226 | +/*!***********************************************************************!*\ | |
| 1227 | + !*** ./node_modules/@tanstack/query-core/build/lib/onlineManager.mjs ***! | |
| 1228 | + \***********************************************************************/ | |
| 953 | 1229 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 954 | 1230 | |
| 955 | 1231 | __webpack_require__.r(__webpack_exports__); |
| 956 | 1232 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -956,490 +1232,582 @@ | ||
| 956 | 1232 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 957 | 1233 | /* harmony export */ OnlineManager: function() { return /* binding */ OnlineManager; }, |
| 958 | 1234 | /* harmony export */ onlineManager: function() { return /* binding */ onlineManager; } |
| 959 | 1235 | /* harmony export */ }); |
| 960 | -/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); | |
| 961 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 962 | -// src/onlineManager.ts | |
| 1236 | +/* harmony import */ var _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.mjs */ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs"); | |
| 1237 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 963 | 1238 | |
| 964 | 1239 | |
| 965 | -var OnlineManager = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 966 | - #online = true; | |
| 967 | - #cleanup; | |
| 968 | - #setup; | |
| 1240 | + | |
| 1241 | +const onlineEvents = ['online', 'offline']; | |
| 1242 | +class OnlineManager extends _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 969 | 1243 | constructor() { |
| 970 | 1244 | super(); |
| 971 | - this.#setup = (onOnline) => { | |
| 972 | - if (!_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { | |
| 973 | - const onlineListener = () => onOnline(true); | |
| 974 | - const offlineListener = () => onOnline(false); | |
| 975 | - window.addEventListener("online", onlineListener, false); | |
| 976 | - window.addEventListener("offline", offlineListener, false); | |
| 1245 | + | |
| 1246 | + this.setup = onOnline => { | |
| 1247 | + // addEventListener does not exist in React Native, but window does | |
| 1248 | + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | |
| 1249 | + if (!_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { | |
| 1250 | + const listener = () => onOnline(); // Listen to online | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + onlineEvents.forEach(event => { | |
| 1254 | + window.addEventListener(event, listener, false); | |
| 1255 | + }); | |
| 977 | 1256 | return () => { |
| 978 | - window.removeEventListener("online", onlineListener); | |
| 979 | - window.removeEventListener("offline", offlineListener); | |
| 1257 | + // Be sure to unsubscribe if a new handler is set | |
| 1258 | + onlineEvents.forEach(event => { | |
| 1259 | + window.removeEventListener(event, listener); | |
| 1260 | + }); | |
| 980 | 1261 | }; |
| 981 | 1262 | } |
| 1263 | + | |
| 982 | 1264 | return; |
| 983 | 1265 | }; |
| 984 | 1266 | } |
| 1267 | + | |
| 985 | 1268 | onSubscribe() { |
| 986 | - if (!this.#cleanup) { | |
| 987 | - this.setEventListener(this.#setup); | |
| 1269 | + if (!this.cleanup) { | |
| 1270 | + this.setEventListener(this.setup); | |
| 988 | 1271 | } |
| 989 | 1272 | } |
| 1273 | + | |
| 990 | 1274 | onUnsubscribe() { |
| 991 | 1275 | if (!this.hasListeners()) { |
| 992 | - this.#cleanup?.(); | |
| 993 | - this.#cleanup = void 0; | |
| 1276 | + var _this$cleanup; | |
| 1277 | + | |
| 1278 | + (_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this); | |
| 1279 | + this.cleanup = undefined; | |
| 994 | 1280 | } |
| 995 | 1281 | } |
| 1282 | + | |
| 996 | 1283 | setEventListener(setup) { |
| 997 | - this.#setup = setup; | |
| 998 | - this.#cleanup?.(); | |
| 999 | - this.#cleanup = setup(this.setOnline.bind(this)); | |
| 1284 | + var _this$cleanup2; | |
| 1285 | + | |
| 1286 | + this.setup = setup; | |
| 1287 | + (_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this); | |
| 1288 | + this.cleanup = setup(online => { | |
| 1289 | + if (typeof online === 'boolean') { | |
| 1290 | + this.setOnline(online); | |
| 1291 | + } else { | |
| 1292 | + this.onOnline(); | |
| 1293 | + } | |
| 1294 | + }); | |
| 1000 | 1295 | } |
| 1296 | + | |
| 1001 | 1297 | setOnline(online) { |
| 1002 | - const changed = this.#online !== online; | |
| 1298 | + const changed = this.online !== online; | |
| 1299 | + | |
| 1003 | 1300 | if (changed) { |
| 1004 | - this.#online = online; | |
| 1005 | - this.listeners.forEach((listener) => { | |
| 1006 | - listener(online); | |
| 1007 | - }); | |
| 1301 | + this.online = online; | |
| 1302 | + this.onOnline(); | |
| 1008 | 1303 | } |
| 1009 | 1304 | } |
| 1305 | + | |
| 1306 | + onOnline() { | |
| 1307 | + this.listeners.forEach(({ | |
| 1308 | + listener | |
| 1309 | + }) => { | |
| 1310 | + listener(); | |
| 1311 | + }); | |
| 1312 | + } | |
| 1313 | + | |
| 1010 | 1314 | isOnline() { |
| 1011 | - return this.#online; | |
| 1315 | + if (typeof this.online === 'boolean') { | |
| 1316 | + return this.online; | |
| 1317 | + } | |
| 1318 | + | |
| 1319 | + if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') { | |
| 1320 | + return true; | |
| 1321 | + } | |
| 1322 | + | |
| 1323 | + return navigator.onLine; | |
| 1012 | 1324 | } |
| 1013 | -}; | |
| 1014 | -var onlineManager = new OnlineManager(); | |
| 1015 | 1325 | |
| 1016 | -//# sourceMappingURL=onlineManager.js.map | |
| 1326 | +} | |
| 1327 | +const onlineManager = new OnlineManager(); | |
| 1017 | 1328 | |
| 1329 | + | |
| 1330 | +//# sourceMappingURL=onlineManager.mjs.map | |
| 1331 | + | |
| 1332 | + | |
| 1018 | 1333 | /***/ }), |
| 1019 | 1334 | |
| 1020 | -/***/ "./node_modules/@tanstack/query-core/build/modern/query.js": | |
| 1021 | -/*!*****************************************************************!*\ | |
| 1022 | - !*** ./node_modules/@tanstack/query-core/build/modern/query.js ***! | |
| 1023 | - \*****************************************************************/ | |
| 1335 | +/***/ "./node_modules/@tanstack/query-core/build/lib/query.mjs": | |
| 1336 | +/*!***************************************************************!*\ | |
| 1337 | + !*** ./node_modules/@tanstack/query-core/build/lib/query.mjs ***! | |
| 1338 | + \***************************************************************/ | |
| 1024 | 1339 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1025 | 1340 | |
| 1026 | 1341 | __webpack_require__.r(__webpack_exports__); |
| 1027 | 1342 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1028 | -/* harmony export */ Query: function() { return /* binding */ Query; }, | |
| 1029 | -/* harmony export */ fetchState: function() { return /* binding */ fetchState; } | |
| 1343 | +/* harmony export */ Query: function() { return /* binding */ Query; } | |
| 1030 | 1344 | /* harmony export */ }); |
| 1031 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 1032 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 1033 | -/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); | |
| 1034 | -/* harmony import */ var _removable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./removable.js */ "./node_modules/@tanstack/query-core/build/modern/removable.js"); | |
| 1035 | -// src/query.ts | |
| 1345 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 1346 | +/* harmony import */ var _logger_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger.mjs */ "./node_modules/@tanstack/query-core/build/lib/logger.mjs"); | |
| 1347 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 1348 | +/* harmony import */ var _retryer_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./retryer.mjs */ "./node_modules/@tanstack/query-core/build/lib/retryer.mjs"); | |
| 1349 | +/* harmony import */ var _removable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./removable.mjs */ "./node_modules/@tanstack/query-core/build/lib/removable.mjs"); | |
| 1036 | 1350 | |
| 1037 | 1351 | |
| 1038 | 1352 | |
| 1039 | 1353 | |
| 1040 | -var Query = class extends _removable_js__WEBPACK_IMPORTED_MODULE_3__.Removable { | |
| 1041 | - #initialState; | |
| 1042 | - #revertState; | |
| 1043 | - #cache; | |
| 1044 | - #client; | |
| 1045 | - #retryer; | |
| 1046 | - #defaultOptions; | |
| 1047 | - #abortSignalConsumed; | |
| 1354 | + | |
| 1355 | + | |
| 1356 | +// CLASS | |
| 1357 | +class Query extends _removable_mjs__WEBPACK_IMPORTED_MODULE_0__.Removable { | |
| 1048 | 1358 | constructor(config) { |
| 1049 | 1359 | super(); |
| 1050 | - this.#abortSignalConsumed = false; | |
| 1051 | - this.#defaultOptions = config.defaultOptions; | |
| 1360 | + this.abortSignalConsumed = false; | |
| 1361 | + this.defaultOptions = config.defaultOptions; | |
| 1052 | 1362 | this.setOptions(config.options); |
| 1053 | 1363 | this.observers = []; |
| 1054 | - this.#client = config.client; | |
| 1055 | - this.#cache = this.#client.getQueryCache(); | |
| 1364 | + this.cache = config.cache; | |
| 1365 | + this.logger = config.logger || _logger_mjs__WEBPACK_IMPORTED_MODULE_1__.defaultLogger; | |
| 1056 | 1366 | this.queryKey = config.queryKey; |
| 1057 | 1367 | this.queryHash = config.queryHash; |
| 1058 | - this.#initialState = getDefaultState(this.options); | |
| 1059 | - this.state = config.state ?? this.#initialState; | |
| 1368 | + this.initialState = config.state || getDefaultState(this.options); | |
| 1369 | + this.state = this.initialState; | |
| 1060 | 1370 | this.scheduleGc(); |
| 1061 | 1371 | } |
| 1372 | + | |
| 1062 | 1373 | get meta() { |
| 1063 | 1374 | return this.options.meta; |
| 1064 | 1375 | } |
| 1065 | - get promise() { | |
| 1066 | - return this.#retryer?.promise; | |
| 1067 | - } | |
| 1376 | + | |
| 1068 | 1377 | setOptions(options) { |
| 1069 | - this.options = { ...this.#defaultOptions, ...options }; | |
| 1070 | - this.updateGcTime(this.options.gcTime); | |
| 1071 | - if (this.state && this.state.data === void 0) { | |
| 1072 | - const defaultState = getDefaultState(this.options); | |
| 1073 | - if (defaultState.data !== void 0) { | |
| 1074 | - this.setState( | |
| 1075 | - successState(defaultState.data, defaultState.dataUpdatedAt) | |
| 1076 | - ); | |
| 1077 | - this.#initialState = defaultState; | |
| 1078 | - } | |
| 1079 | - } | |
| 1378 | + this.options = { ...this.defaultOptions, | |
| 1379 | + ...options | |
| 1380 | + }; | |
| 1381 | + this.updateCacheTime(this.options.cacheTime); | |
| 1080 | 1382 | } |
| 1383 | + | |
| 1081 | 1384 | optionalRemove() { |
| 1082 | - if (!this.observers.length && this.state.fetchStatus === "idle") { | |
| 1083 | - this.#cache.remove(this); | |
| 1385 | + if (!this.observers.length && this.state.fetchStatus === 'idle') { | |
| 1386 | + this.cache.remove(this); | |
| 1084 | 1387 | } |
| 1085 | 1388 | } |
| 1389 | + | |
| 1086 | 1390 | setData(newData, options) { |
| 1087 | - const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.replaceData)(this.state.data, newData, this.options); | |
| 1088 | - this.#dispatch({ | |
| 1391 | + const data = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_2__.replaceData)(this.state.data, newData, this.options); // Set data and mark it as cached | |
| 1392 | + | |
| 1393 | + this.dispatch({ | |
| 1089 | 1394 | data, |
| 1090 | - type: "success", | |
| 1091 | - dataUpdatedAt: options?.updatedAt, | |
| 1092 | - manual: options?.manual | |
| 1395 | + type: 'success', | |
| 1396 | + dataUpdatedAt: options == null ? void 0 : options.updatedAt, | |
| 1397 | + manual: options == null ? void 0 : options.manual | |
| 1093 | 1398 | }); |
| 1094 | 1399 | return data; |
| 1095 | 1400 | } |
| 1401 | + | |
| 1096 | 1402 | setState(state, setStateOptions) { |
| 1097 | - this.#dispatch({ type: "setState", state, setStateOptions }); | |
| 1403 | + this.dispatch({ | |
| 1404 | + type: 'setState', | |
| 1405 | + state, | |
| 1406 | + setStateOptions | |
| 1407 | + }); | |
| 1098 | 1408 | } |
| 1409 | + | |
| 1099 | 1410 | cancel(options) { |
| 1100 | - const promise = this.#retryer?.promise; | |
| 1101 | - this.#retryer?.cancel(options); | |
| 1102 | - return promise ? promise.then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop) : Promise.resolve(); | |
| 1411 | + var _this$retryer; | |
| 1412 | + | |
| 1413 | + const promise = this.promise; | |
| 1414 | + (_this$retryer = this.retryer) == null ? void 0 : _this$retryer.cancel(options); | |
| 1415 | + return promise ? promise.then(_utils_mjs__WEBPACK_IMPORTED_MODULE_2__.noop).catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_2__.noop) : Promise.resolve(); | |
| 1103 | 1416 | } |
| 1417 | + | |
| 1104 | 1418 | destroy() { |
| 1105 | 1419 | super.destroy(); |
| 1106 | - this.cancel({ silent: true }); | |
| 1420 | + this.cancel({ | |
| 1421 | + silent: true | |
| 1422 | + }); | |
| 1107 | 1423 | } |
| 1424 | + | |
| 1108 | 1425 | reset() { |
| 1109 | 1426 | this.destroy(); |
| 1110 | - this.setState(this.#initialState); | |
| 1427 | + this.setState(this.initialState); | |
| 1111 | 1428 | } |
| 1429 | + | |
| 1112 | 1430 | isActive() { |
| 1113 | - return this.observers.some( | |
| 1114 | - (observer) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveEnabled)(observer.options.enabled, this) !== false | |
| 1115 | - ); | |
| 1431 | + return this.observers.some(observer => observer.options.enabled !== false); | |
| 1116 | 1432 | } |
| 1433 | + | |
| 1117 | 1434 | isDisabled() { |
| 1118 | - if (this.getObserversCount() > 0) { | |
| 1119 | - return !this.isActive(); | |
| 1120 | - } | |
| 1121 | - return this.options.queryFn === _utils_js__WEBPACK_IMPORTED_MODULE_0__.skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0; | |
| 1435 | + return this.getObserversCount() > 0 && !this.isActive(); | |
| 1122 | 1436 | } |
| 1123 | - isStatic() { | |
| 1124 | - if (this.getObserversCount() > 0) { | |
| 1125 | - return this.observers.some( | |
| 1126 | - (observer) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveStaleTime)(observer.options.staleTime, this) === "static" | |
| 1127 | - ); | |
| 1128 | - } | |
| 1129 | - return false; | |
| 1130 | - } | |
| 1437 | + | |
| 1131 | 1438 | isStale() { |
| 1132 | - if (this.getObserversCount() > 0) { | |
| 1133 | - return this.observers.some( | |
| 1134 | - (observer) => observer.getCurrentResult().isStale | |
| 1135 | - ); | |
| 1136 | - } | |
| 1137 | - return this.state.data === void 0 || this.state.isInvalidated; | |
| 1439 | + return this.state.isInvalidated || !this.state.dataUpdatedAt || this.observers.some(observer => observer.getCurrentResult().isStale); | |
| 1138 | 1440 | } |
| 1441 | + | |
| 1139 | 1442 | isStaleByTime(staleTime = 0) { |
| 1140 | - if (this.state.data === void 0) { | |
| 1141 | - return true; | |
| 1142 | - } | |
| 1143 | - if (staleTime === "static") { | |
| 1144 | - return false; | |
| 1145 | - } | |
| 1146 | - if (this.state.isInvalidated) { | |
| 1147 | - return true; | |
| 1148 | - } | |
| 1149 | - return !(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.timeUntilStale)(this.state.dataUpdatedAt, staleTime); | |
| 1443 | + return this.state.isInvalidated || !this.state.dataUpdatedAt || !(0,_utils_mjs__WEBPACK_IMPORTED_MODULE_2__.timeUntilStale)(this.state.dataUpdatedAt, staleTime); | |
| 1150 | 1444 | } |
| 1445 | + | |
| 1151 | 1446 | onFocus() { |
| 1152 | - const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus()); | |
| 1153 | - observer?.refetch({ cancelRefetch: false }); | |
| 1154 | - this.#retryer?.continue(); | |
| 1447 | + var _this$retryer2; | |
| 1448 | + | |
| 1449 | + const observer = this.observers.find(x => x.shouldFetchOnWindowFocus()); | |
| 1450 | + | |
| 1451 | + if (observer) { | |
| 1452 | + observer.refetch({ | |
| 1453 | + cancelRefetch: false | |
| 1454 | + }); | |
| 1455 | + } // Continue fetch if currently paused | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + (_this$retryer2 = this.retryer) == null ? void 0 : _this$retryer2.continue(); | |
| 1155 | 1459 | } |
| 1460 | + | |
| 1156 | 1461 | onOnline() { |
| 1157 | - const observer = this.observers.find((x) => x.shouldFetchOnReconnect()); | |
| 1158 | - observer?.refetch({ cancelRefetch: false }); | |
| 1159 | - this.#retryer?.continue(); | |
| 1462 | + var _this$retryer3; | |
| 1463 | + | |
| 1464 | + const observer = this.observers.find(x => x.shouldFetchOnReconnect()); | |
| 1465 | + | |
| 1466 | + if (observer) { | |
| 1467 | + observer.refetch({ | |
| 1468 | + cancelRefetch: false | |
| 1469 | + }); | |
| 1470 | + } // Continue fetch if currently paused | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + (_this$retryer3 = this.retryer) == null ? void 0 : _this$retryer3.continue(); | |
| 1160 | 1474 | } |
| 1475 | + | |
| 1161 | 1476 | addObserver(observer) { |
| 1162 | 1477 | if (!this.observers.includes(observer)) { |
| 1163 | - this.observers.push(observer); | |
| 1478 | + this.observers.push(observer); // Stop the query from being garbage collected | |
| 1479 | + | |
| 1164 | 1480 | this.clearGcTimeout(); |
| 1165 | - this.#cache.notify({ type: "observerAdded", query: this, observer }); | |
| 1481 | + this.cache.notify({ | |
| 1482 | + type: 'observerAdded', | |
| 1483 | + query: this, | |
| 1484 | + observer | |
| 1485 | + }); | |
| 1166 | 1486 | } |
| 1167 | 1487 | } |
| 1488 | + | |
| 1168 | 1489 | removeObserver(observer) { |
| 1169 | 1490 | if (this.observers.includes(observer)) { |
| 1170 | - this.observers = this.observers.filter((x) => x !== observer); | |
| 1491 | + this.observers = this.observers.filter(x => x !== observer); | |
| 1492 | + | |
| 1171 | 1493 | if (!this.observers.length) { |
| 1172 | - if (this.#retryer) { | |
| 1173 | - if (this.#abortSignalConsumed) { | |
| 1174 | - this.#retryer.cancel({ revert: true }); | |
| 1494 | + // If the transport layer does not support cancellation | |
| 1495 | + // we'll let the query continue so the result can be cached | |
| 1496 | + if (this.retryer) { | |
| 1497 | + if (this.abortSignalConsumed) { | |
| 1498 | + this.retryer.cancel({ | |
| 1499 | + revert: true | |
| 1500 | + }); | |
| 1175 | 1501 | } else { |
| 1176 | - this.#retryer.cancelRetry(); | |
| 1502 | + this.retryer.cancelRetry(); | |
| 1177 | 1503 | } |
| 1178 | 1504 | } |
| 1505 | + | |
| 1179 | 1506 | this.scheduleGc(); |
| 1180 | 1507 | } |
| 1181 | - this.#cache.notify({ type: "observerRemoved", query: this, observer }); | |
| 1508 | + | |
| 1509 | + this.cache.notify({ | |
| 1510 | + type: 'observerRemoved', | |
| 1511 | + query: this, | |
| 1512 | + observer | |
| 1513 | + }); | |
| 1182 | 1514 | } |
| 1183 | 1515 | } |
| 1516 | + | |
| 1184 | 1517 | getObserversCount() { |
| 1185 | 1518 | return this.observers.length; |
| 1186 | 1519 | } |
| 1520 | + | |
| 1187 | 1521 | invalidate() { |
| 1188 | 1522 | if (!this.state.isInvalidated) { |
| 1189 | - this.#dispatch({ type: "invalidate" }); | |
| 1523 | + this.dispatch({ | |
| 1524 | + type: 'invalidate' | |
| 1525 | + }); | |
| 1190 | 1526 | } |
| 1191 | 1527 | } |
| 1192 | - async fetch(options, fetchOptions) { | |
| 1193 | - if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely | |
| 1194 | - // re-start the fetch; there is a chance that the query is still in a | |
| 1195 | - // pending state when that happens | |
| 1196 | - this.#retryer?.status() !== "rejected") { | |
| 1197 | - if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) { | |
| 1198 | - this.cancel({ silent: true }); | |
| 1199 | - } else if (this.#retryer) { | |
| 1200 | - this.#retryer.continueRetry(); | |
| 1201 | - return this.#retryer.promise; | |
| 1528 | + | |
| 1529 | + fetch(options, fetchOptions) { | |
| 1530 | + var _this$options$behavio, _context$fetchOptions; | |
| 1531 | + | |
| 1532 | + if (this.state.fetchStatus !== 'idle') { | |
| 1533 | + if (this.state.dataUpdatedAt && fetchOptions != null && fetchOptions.cancelRefetch) { | |
| 1534 | + // Silently cancel current fetch if the user wants to cancel refetches | |
| 1535 | + this.cancel({ | |
| 1536 | + silent: true | |
| 1537 | + }); | |
| 1538 | + } else if (this.promise) { | |
| 1539 | + var _this$retryer4; | |
| 1540 | + | |
| 1541 | + // make sure that retries that were potentially cancelled due to unmounts can continue | |
| 1542 | + (_this$retryer4 = this.retryer) == null ? void 0 : _this$retryer4.continueRetry(); // Return current promise if we are already fetching | |
| 1543 | + | |
| 1544 | + return this.promise; | |
| 1202 | 1545 | } |
| 1203 | - } | |
| 1546 | + } // Update config if passed, otherwise the config from the last execution is used | |
| 1547 | + | |
| 1548 | + | |
| 1204 | 1549 | if (options) { |
| 1205 | 1550 | this.setOptions(options); |
| 1206 | - } | |
| 1551 | + } // Use the options from the first observer with a query function if no function is found. | |
| 1552 | + // This can happen when the query is hydrated or created with setQueryData. | |
| 1553 | + | |
| 1554 | + | |
| 1207 | 1555 | if (!this.options.queryFn) { |
| 1208 | - const observer = this.observers.find((x) => x.options.queryFn); | |
| 1556 | + const observer = this.observers.find(x => x.options.queryFn); | |
| 1557 | + | |
| 1209 | 1558 | if (observer) { |
| 1210 | 1559 | this.setOptions(observer.options); |
| 1211 | 1560 | } |
| 1212 | 1561 | } |
| 1213 | - if (true) { | |
| 1214 | - if (!Array.isArray(this.options.queryKey)) { | |
| 1215 | - console.error( | |
| 1216 | - `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']` | |
| 1217 | - ); | |
| 1562 | + | |
| 1563 | + if (!Array.isArray(this.options.queryKey)) { | |
| 1564 | + if (true) { | |
| 1565 | + this.logger.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"); | |
| 1218 | 1566 | } |
| 1219 | 1567 | } |
| 1220 | - const abortController = new AbortController(); | |
| 1221 | - const addSignalProperty = (object) => { | |
| 1222 | - Object.defineProperty(object, "signal", { | |
| 1568 | + | |
| 1569 | + const abortController = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_2__.getAbortController)(); // Create query function context | |
| 1570 | + | |
| 1571 | + const queryFnContext = { | |
| 1572 | + queryKey: this.queryKey, | |
| 1573 | + pageParam: undefined, | |
| 1574 | + meta: this.meta | |
| 1575 | + }; // Adds an enumerable signal property to the object that | |
| 1576 | + // which sets abortSignalConsumed to true when the signal | |
| 1577 | + // is read. | |
| 1578 | + | |
| 1579 | + const addSignalProperty = object => { | |
| 1580 | + Object.defineProperty(object, 'signal', { | |
| 1223 | 1581 | enumerable: true, |
| 1224 | 1582 | get: () => { |
| 1225 | - this.#abortSignalConsumed = true; | |
| 1226 | - return abortController.signal; | |
| 1583 | + if (abortController) { | |
| 1584 | + this.abortSignalConsumed = true; | |
| 1585 | + return abortController.signal; | |
| 1586 | + } | |
| 1587 | + | |
| 1588 | + return undefined; | |
| 1227 | 1589 | } |
| 1228 | 1590 | }); |
| 1229 | 1591 | }; |
| 1592 | + | |
| 1593 | + addSignalProperty(queryFnContext); // Create fetch function | |
| 1594 | + | |
| 1230 | 1595 | const fetchFn = () => { |
| 1231 | - const queryFn = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureQueryFn)(this.options, fetchOptions); | |
| 1232 | - const createQueryFnContext = () => { | |
| 1233 | - const queryFnContext2 = { | |
| 1234 | - client: this.#client, | |
| 1235 | - queryKey: this.queryKey, | |
| 1236 | - meta: this.meta | |
| 1237 | - }; | |
| 1238 | - addSignalProperty(queryFnContext2); | |
| 1239 | - return queryFnContext2; | |
| 1240 | - }; | |
| 1241 | - const queryFnContext = createQueryFnContext(); | |
| 1242 | - this.#abortSignalConsumed = false; | |
| 1243 | - if (this.options.persister) { | |
| 1244 | - return this.options.persister( | |
| 1245 | - queryFn, | |
| 1246 | - queryFnContext, | |
| 1247 | - this | |
| 1248 | - ); | |
| 1596 | + if (!this.options.queryFn) { | |
| 1597 | + return Promise.reject("Missing queryFn for queryKey '" + this.options.queryHash + "'"); | |
| 1249 | 1598 | } |
| 1250 | - return queryFn(queryFnContext); | |
| 1599 | + | |
| 1600 | + this.abortSignalConsumed = false; | |
| 1601 | + return this.options.queryFn(queryFnContext); | |
| 1602 | + }; // Trigger behavior hook | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + const context = { | |
| 1606 | + fetchOptions, | |
| 1607 | + options: this.options, | |
| 1608 | + queryKey: this.queryKey, | |
| 1609 | + state: this.state, | |
| 1610 | + fetchFn | |
| 1251 | 1611 | }; |
| 1252 | - const createFetchContext = () => { | |
| 1253 | - const context2 = { | |
| 1254 | - fetchOptions, | |
| 1255 | - options: this.options, | |
| 1256 | - queryKey: this.queryKey, | |
| 1257 | - client: this.#client, | |
| 1258 | - state: this.state, | |
| 1259 | - fetchFn | |
| 1260 | - }; | |
| 1261 | - addSignalProperty(context2); | |
| 1262 | - return context2; | |
| 1263 | - }; | |
| 1264 | - const context = createFetchContext(); | |
| 1265 | - this.options.behavior?.onFetch(context, this); | |
| 1266 | - this.#revertState = this.state; | |
| 1267 | - if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) { | |
| 1268 | - this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta }); | |
| 1612 | + addSignalProperty(context); | |
| 1613 | + (_this$options$behavio = this.options.behavior) == null ? void 0 : _this$options$behavio.onFetch(context); // Store state in case the current fetch needs to be reverted | |
| 1614 | + | |
| 1615 | + this.revertState = this.state; // Set to fetching state if not already in it | |
| 1616 | + | |
| 1617 | + if (this.state.fetchStatus === 'idle' || this.state.fetchMeta !== ((_context$fetchOptions = context.fetchOptions) == null ? void 0 : _context$fetchOptions.meta)) { | |
| 1618 | + var _context$fetchOptions2; | |
| 1619 | + | |
| 1620 | + this.dispatch({ | |
| 1621 | + type: 'fetch', | |
| 1622 | + meta: (_context$fetchOptions2 = context.fetchOptions) == null ? void 0 : _context$fetchOptions2.meta | |
| 1623 | + }); | |
| 1269 | 1624 | } |
| 1270 | - this.#retryer = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.createRetryer)({ | |
| 1271 | - initialPromise: fetchOptions?.initialPromise, | |
| 1625 | + | |
| 1626 | + const onError = error => { | |
| 1627 | + // Optimistically update state if needed | |
| 1628 | + if (!((0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.isCancelledError)(error) && error.silent)) { | |
| 1629 | + this.dispatch({ | |
| 1630 | + type: 'error', | |
| 1631 | + error: error | |
| 1632 | + }); | |
| 1633 | + } | |
| 1634 | + | |
| 1635 | + if (!(0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.isCancelledError)(error)) { | |
| 1636 | + var _this$cache$config$on, _this$cache$config, _this$cache$config$on2, _this$cache$config2; | |
| 1637 | + | |
| 1638 | + // Notify cache callback | |
| 1639 | + (_this$cache$config$on = (_this$cache$config = this.cache.config).onError) == null ? void 0 : _this$cache$config$on.call(_this$cache$config, error, this); | |
| 1640 | + (_this$cache$config$on2 = (_this$cache$config2 = this.cache.config).onSettled) == null ? void 0 : _this$cache$config$on2.call(_this$cache$config2, this.state.data, error, this); | |
| 1641 | + | |
| 1642 | + if (true) { | |
| 1643 | + this.logger.error(error); | |
| 1644 | + } | |
| 1645 | + } | |
| 1646 | + | |
| 1647 | + if (!this.isFetchingOptimistic) { | |
| 1648 | + // Schedule query gc after fetching | |
| 1649 | + this.scheduleGc(); | |
| 1650 | + } | |
| 1651 | + | |
| 1652 | + this.isFetchingOptimistic = false; | |
| 1653 | + }; // Try to fetch the data | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + this.retryer = (0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.createRetryer)({ | |
| 1272 | 1657 | fn: context.fetchFn, |
| 1273 | - onCancel: (error) => { | |
| 1274 | - if (error instanceof _retryer_js__WEBPACK_IMPORTED_MODULE_2__.CancelledError && error.revert) { | |
| 1275 | - this.setState({ | |
| 1276 | - ...this.#revertState, | |
| 1277 | - fetchStatus: "idle" | |
| 1278 | - }); | |
| 1658 | + abort: abortController == null ? void 0 : abortController.abort.bind(abortController), | |
| 1659 | + onSuccess: data => { | |
| 1660 | + var _this$cache$config$on3, _this$cache$config3, _this$cache$config$on4, _this$cache$config4; | |
| 1661 | + | |
| 1662 | + if (typeof data === 'undefined') { | |
| 1663 | + if (true) { | |
| 1664 | + this.logger.error("Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: " + this.queryHash); | |
| 1665 | + } | |
| 1666 | + | |
| 1667 | + onError(new Error(this.queryHash + " data is undefined")); | |
| 1668 | + return; | |
| 1279 | 1669 | } |
| 1280 | - abortController.abort(); | |
| 1670 | + | |
| 1671 | + this.setData(data); // Notify cache callback | |
| 1672 | + | |
| 1673 | + (_this$cache$config$on3 = (_this$cache$config3 = this.cache.config).onSuccess) == null ? void 0 : _this$cache$config$on3.call(_this$cache$config3, data, this); | |
| 1674 | + (_this$cache$config$on4 = (_this$cache$config4 = this.cache.config).onSettled) == null ? void 0 : _this$cache$config$on4.call(_this$cache$config4, data, this.state.error, this); | |
| 1675 | + | |
| 1676 | + if (!this.isFetchingOptimistic) { | |
| 1677 | + // Schedule query gc after fetching | |
| 1678 | + this.scheduleGc(); | |
| 1679 | + } | |
| 1680 | + | |
| 1681 | + this.isFetchingOptimistic = false; | |
| 1281 | 1682 | }, |
| 1683 | + onError, | |
| 1282 | 1684 | onFail: (failureCount, error) => { |
| 1283 | - this.#dispatch({ type: "failed", failureCount, error }); | |
| 1685 | + this.dispatch({ | |
| 1686 | + type: 'failed', | |
| 1687 | + failureCount, | |
| 1688 | + error | |
| 1689 | + }); | |
| 1284 | 1690 | }, |
| 1285 | 1691 | onPause: () => { |
| 1286 | - this.#dispatch({ type: "pause" }); | |
| 1692 | + this.dispatch({ | |
| 1693 | + type: 'pause' | |
| 1694 | + }); | |
| 1287 | 1695 | }, |
| 1288 | 1696 | onContinue: () => { |
| 1289 | - this.#dispatch({ type: "continue" }); | |
| 1697 | + this.dispatch({ | |
| 1698 | + type: 'continue' | |
| 1699 | + }); | |
| 1290 | 1700 | }, |
| 1291 | 1701 | retry: context.options.retry, |
| 1292 | 1702 | retryDelay: context.options.retryDelay, |
| 1293 | - networkMode: context.options.networkMode, | |
| 1294 | - canRun: () => true | |
| 1703 | + networkMode: context.options.networkMode | |
| 1295 | 1704 | }); |
| 1296 | - try { | |
| 1297 | - const data = await this.#retryer.start(); | |
| 1298 | - if (data === void 0) { | |
| 1299 | - if (true) { | |
| 1300 | - console.error( | |
| 1301 | - `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}` | |
| 1302 | - ); | |
| 1303 | - } | |
| 1304 | - throw new Error(`${this.queryHash} data is undefined`); | |
| 1305 | - } | |
| 1306 | - this.setData(data); | |
| 1307 | - this.#cache.config.onSuccess?.(data, this); | |
| 1308 | - this.#cache.config.onSettled?.( | |
| 1309 | - data, | |
| 1310 | - this.state.error, | |
| 1311 | - this | |
| 1312 | - ); | |
| 1313 | - return data; | |
| 1314 | - } catch (error) { | |
| 1315 | - if (error instanceof _retryer_js__WEBPACK_IMPORTED_MODULE_2__.CancelledError) { | |
| 1316 | - if (error.silent) { | |
| 1317 | - return this.#retryer.promise; | |
| 1318 | - } else if (error.revert) { | |
| 1319 | - if (this.state.data === void 0) { | |
| 1320 | - throw error; | |
| 1321 | - } | |
| 1322 | - return this.state.data; | |
| 1323 | - } | |
| 1324 | - } | |
| 1325 | - this.#dispatch({ | |
| 1326 | - type: "error", | |
| 1327 | - error | |
| 1328 | - }); | |
| 1329 | - this.#cache.config.onError?.( | |
| 1330 | - error, | |
| 1331 | - this | |
| 1332 | - ); | |
| 1333 | - this.#cache.config.onSettled?.( | |
| 1334 | - this.state.data, | |
| 1335 | - error, | |
| 1336 | - this | |
| 1337 | - ); | |
| 1338 | - throw error; | |
| 1339 | - } finally { | |
| 1340 | - this.scheduleGc(); | |
| 1341 | - } | |
| 1705 | + this.promise = this.retryer.promise; | |
| 1706 | + return this.promise; | |
| 1342 | 1707 | } |
| 1343 | - #dispatch(action) { | |
| 1344 | - const reducer = (state) => { | |
| 1708 | + | |
| 1709 | + dispatch(action) { | |
| 1710 | + const reducer = state => { | |
| 1711 | + var _action$meta, _action$dataUpdatedAt; | |
| 1712 | + | |
| 1345 | 1713 | switch (action.type) { |
| 1346 | - case "failed": | |
| 1347 | - return { | |
| 1348 | - ...state, | |
| 1714 | + case 'failed': | |
| 1715 | + return { ...state, | |
| 1349 | 1716 | fetchFailureCount: action.failureCount, |
| 1350 | 1717 | fetchFailureReason: action.error |
| 1351 | 1718 | }; |
| 1352 | - case "pause": | |
| 1353 | - return { | |
| 1354 | - ...state, | |
| 1355 | - fetchStatus: "paused" | |
| 1719 | + | |
| 1720 | + case 'pause': | |
| 1721 | + return { ...state, | |
| 1722 | + fetchStatus: 'paused' | |
| 1356 | 1723 | }; |
| 1357 | - case "continue": | |
| 1358 | - return { | |
| 1359 | - ...state, | |
| 1360 | - fetchStatus: "fetching" | |
| 1724 | + | |
| 1725 | + case 'continue': | |
| 1726 | + return { ...state, | |
| 1727 | + fetchStatus: 'fetching' | |
| 1361 | 1728 | }; |
| 1362 | - case "fetch": | |
| 1363 | - return { | |
| 1364 | - ...state, | |
| 1365 | - ...fetchState(state.data, this.options), | |
| 1366 | - fetchMeta: action.meta ?? null | |
| 1729 | + | |
| 1730 | + case 'fetch': | |
| 1731 | + return { ...state, | |
| 1732 | + fetchFailureCount: 0, | |
| 1733 | + fetchFailureReason: null, | |
| 1734 | + fetchMeta: (_action$meta = action.meta) != null ? _action$meta : null, | |
| 1735 | + fetchStatus: (0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.canFetch)(this.options.networkMode) ? 'fetching' : 'paused', | |
| 1736 | + ...(!state.dataUpdatedAt && { | |
| 1737 | + error: null, | |
| 1738 | + status: 'loading' | |
| 1739 | + }) | |
| 1367 | 1740 | }; |
| 1368 | - case "success": | |
| 1369 | - const newState = { | |
| 1370 | - ...state, | |
| 1371 | - ...successState(action.data, action.dataUpdatedAt), | |
| 1741 | + | |
| 1742 | + case 'success': | |
| 1743 | + return { ...state, | |
| 1744 | + data: action.data, | |
| 1372 | 1745 | dataUpdateCount: state.dataUpdateCount + 1, |
| 1373 | - ...!action.manual && { | |
| 1374 | - fetchStatus: "idle", | |
| 1746 | + dataUpdatedAt: (_action$dataUpdatedAt = action.dataUpdatedAt) != null ? _action$dataUpdatedAt : Date.now(), | |
| 1747 | + error: null, | |
| 1748 | + isInvalidated: false, | |
| 1749 | + status: 'success', | |
| 1750 | + ...(!action.manual && { | |
| 1751 | + fetchStatus: 'idle', | |
| 1375 | 1752 | fetchFailureCount: 0, |
| 1376 | 1753 | fetchFailureReason: null |
| 1377 | - } | |
| 1754 | + }) | |
| 1378 | 1755 | }; |
| 1379 | - this.#revertState = action.manual ? newState : void 0; | |
| 1380 | - return newState; | |
| 1381 | - case "error": | |
| 1756 | + | |
| 1757 | + case 'error': | |
| 1382 | 1758 | const error = action.error; |
| 1383 | - return { | |
| 1384 | - ...state, | |
| 1385 | - error, | |
| 1759 | + | |
| 1760 | + if ((0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.isCancelledError)(error) && error.revert && this.revertState) { | |
| 1761 | + return { ...this.revertState | |
| 1762 | + }; | |
| 1763 | + } | |
| 1764 | + | |
| 1765 | + return { ...state, | |
| 1766 | + error: error, | |
| 1386 | 1767 | errorUpdateCount: state.errorUpdateCount + 1, |
| 1387 | 1768 | errorUpdatedAt: Date.now(), |
| 1388 | 1769 | fetchFailureCount: state.fetchFailureCount + 1, |
| 1389 | 1770 | fetchFailureReason: error, |
| 1390 | - fetchStatus: "idle", | |
| 1391 | - status: "error" | |
| 1771 | + fetchStatus: 'idle', | |
| 1772 | + status: 'error' | |
| 1392 | 1773 | }; |
| 1393 | - case "invalidate": | |
| 1394 | - return { | |
| 1395 | - ...state, | |
| 1774 | + | |
| 1775 | + case 'invalidate': | |
| 1776 | + return { ...state, | |
| 1396 | 1777 | isInvalidated: true |
| 1397 | 1778 | }; |
| 1398 | - case "setState": | |
| 1399 | - return { | |
| 1400 | - ...state, | |
| 1779 | + | |
| 1780 | + case 'setState': | |
| 1781 | + return { ...state, | |
| 1401 | 1782 | ...action.state |
| 1402 | 1783 | }; |
| 1403 | 1784 | } |
| 1404 | 1785 | }; |
| 1786 | + | |
| 1405 | 1787 | this.state = reducer(this.state); |
| 1406 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batch(() => { | |
| 1407 | - this.observers.forEach((observer) => { | |
| 1408 | - observer.onQueryUpdate(); | |
| 1788 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batch(() => { | |
| 1789 | + this.observers.forEach(observer => { | |
| 1790 | + observer.onQueryUpdate(action); | |
| 1409 | 1791 | }); |
| 1410 | - this.#cache.notify({ query: this, type: "updated", action }); | |
| 1792 | + this.cache.notify({ | |
| 1793 | + query: this, | |
| 1794 | + type: 'updated', | |
| 1795 | + action | |
| 1796 | + }); | |
| 1411 | 1797 | }); |
| 1412 | 1798 | } |
| 1413 | -}; | |
| 1414 | -function fetchState(data, options) { | |
| 1415 | - return { | |
| 1416 | - fetchFailureCount: 0, | |
| 1417 | - fetchFailureReason: null, | |
| 1418 | - fetchStatus: (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.canFetch)(options.networkMode) ? "fetching" : "paused", | |
| 1419 | - ...data === void 0 && { | |
| 1420 | - error: null, | |
| 1421 | - status: "pending" | |
| 1422 | - } | |
| 1423 | - }; | |
| 1799 | + | |
| 1424 | 1800 | } |
| 1425 | -function successState(data, dataUpdatedAt) { | |
| 1426 | - return { | |
| 1427 | - data, | |
| 1428 | - dataUpdatedAt: dataUpdatedAt ?? Date.now(), | |
| 1429 | - error: null, | |
| 1430 | - isInvalidated: false, | |
| 1431 | - status: "success" | |
| 1432 | - }; | |
| 1433 | -} | |
| 1801 | + | |
| 1434 | 1802 | function getDefaultState(options) { |
| 1435 | - const data = typeof options.initialData === "function" ? options.initialData() : options.initialData; | |
| 1436 | - const hasData = data !== void 0; | |
| 1437 | - const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; | |
| 1803 | + const data = typeof options.initialData === 'function' ? options.initialData() : options.initialData; | |
| 1804 | + const hasData = typeof data !== 'undefined'; | |
| 1805 | + const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; | |
| 1438 | 1806 | return { |
| 1439 | 1807 | data, |
| 1440 | 1808 | dataUpdateCount: 0, |
| 1441 | - dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0, | |
| 1809 | + dataUpdatedAt: hasData ? initialDataUpdatedAt != null ? initialDataUpdatedAt : Date.now() : 0, | |
| 1442 | 1810 | error: null, |
| 1443 | 1811 | errorUpdateCount: 0, |
| 1444 | 1812 | errorUpdatedAt: 0, |
| 1445 | 1813 | fetchFailureCount: 0, |
| @@ -1445,21 +1813,23 @@ | ||
| 1445 | 1813 | fetchFailureCount: 0, |
| 1446 | 1814 | fetchFailureReason: null, |
| 1447 | 1815 | fetchMeta: null, |
| 1448 | 1816 | isInvalidated: false, |
| 1449 | - status: hasData ? "success" : "pending", | |
| 1450 | - fetchStatus: "idle" | |
| 1817 | + status: hasData ? 'success' : 'loading', | |
| 1818 | + fetchStatus: 'idle' | |
| 1451 | 1819 | }; |
| 1452 | 1820 | } |
| 1453 | 1821 | |
| 1454 | -//# sourceMappingURL=query.js.map | |
| 1455 | 1822 | |
| 1823 | +//# sourceMappingURL=query.mjs.map | |
| 1824 | + | |
| 1825 | + | |
| 1456 | 1826 | /***/ }), |
| 1457 | 1827 | |
| 1458 | -/***/ "./node_modules/@tanstack/query-core/build/modern/queryCache.js": | |
| 1459 | -/*!**********************************************************************!*\ | |
| 1460 | - !*** ./node_modules/@tanstack/query-core/build/modern/queryCache.js ***! | |
| 1461 | - \**********************************************************************/ | |
| 1828 | +/***/ "./node_modules/@tanstack/query-core/build/lib/queryCache.mjs": | |
| 1829 | +/*!********************************************************************!*\ | |
| 1830 | + !*** ./node_modules/@tanstack/query-core/build/lib/queryCache.mjs ***! | |
| 1831 | + \********************************************************************/ | |
| 1462 | 1832 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1463 | 1833 | |
| 1464 | 1834 | __webpack_require__.r(__webpack_exports__); |
| 1465 | 1835 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -1464,31 +1834,37 @@ | ||
| 1464 | 1834 | __webpack_require__.r(__webpack_exports__); |
| 1465 | 1835 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1466 | 1836 | /* harmony export */ QueryCache: function() { return /* binding */ QueryCache; } |
| 1467 | 1837 | /* harmony export */ }); |
| 1468 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 1469 | -/* harmony import */ var _query_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./query.js */ "./node_modules/@tanstack/query-core/build/modern/query.js"); | |
| 1470 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 1471 | -/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); | |
| 1472 | -// src/queryCache.ts | |
| 1838 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 1839 | +/* harmony import */ var _query_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./query.mjs */ "./node_modules/@tanstack/query-core/build/lib/query.mjs"); | |
| 1840 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 1841 | +/* harmony import */ var _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.mjs */ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs"); | |
| 1473 | 1842 | |
| 1474 | 1843 | |
| 1475 | 1844 | |
| 1476 | 1845 | |
| 1477 | -var QueryCache = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_3__.Subscribable { | |
| 1478 | - constructor(config = {}) { | |
| 1846 | + | |
| 1847 | +// CLASS | |
| 1848 | +class QueryCache extends _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 1849 | + constructor(config) { | |
| 1479 | 1850 | super(); |
| 1480 | - this.config = config; | |
| 1481 | - this.#queries = /* @__PURE__ */ new Map(); | |
| 1851 | + this.config = config || {}; | |
| 1852 | + this.queries = []; | |
| 1853 | + this.queriesMap = {}; | |
| 1482 | 1854 | } |
| 1483 | - #queries; | |
| 1855 | + | |
| 1484 | 1856 | build(client, options, state) { |
| 1857 | + var _options$queryHash; | |
| 1858 | + | |
| 1485 | 1859 | const queryKey = options.queryKey; |
| 1486 | - const queryHash = options.queryHash ?? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashQueryKeyByOptions)(queryKey, options); | |
| 1860 | + const queryHash = (_options$queryHash = options.queryHash) != null ? _options$queryHash : (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.hashQueryKeyByOptions)(queryKey, options); | |
| 1487 | 1861 | let query = this.get(queryHash); |
| 1862 | + | |
| 1488 | 1863 | if (!query) { |
| 1489 | - query = new _query_js__WEBPACK_IMPORTED_MODULE_1__.Query({ | |
| 1490 | - client, | |
| 1864 | + query = new _query_mjs__WEBPACK_IMPORTED_MODULE_2__.Query({ | |
| 1865 | + cache: this, | |
| 1866 | + logger: client.getLogger(), | |
| 1491 | 1867 | queryKey, |
| 1492 | 1868 | queryHash, |
| 1493 | 1869 | options: client.defaultQueryOptions(options), |
| 1494 | 1870 | state, |
| @@ -1495,83 +1871,110 @@ | ||
| 1495 | 1871 | defaultOptions: client.getQueryDefaults(queryKey) |
| 1496 | 1872 | }); |
| 1497 | 1873 | this.add(query); |
| 1498 | 1874 | } |
| 1875 | + | |
| 1499 | 1876 | return query; |
| 1500 | 1877 | } |
| 1878 | + | |
| 1501 | 1879 | add(query) { |
| 1502 | - if (!this.#queries.has(query.queryHash)) { | |
| 1503 | - this.#queries.set(query.queryHash, query); | |
| 1880 | + if (!this.queriesMap[query.queryHash]) { | |
| 1881 | + this.queriesMap[query.queryHash] = query; | |
| 1882 | + this.queries.push(query); | |
| 1504 | 1883 | this.notify({ |
| 1505 | - type: "added", | |
| 1884 | + type: 'added', | |
| 1506 | 1885 | query |
| 1507 | 1886 | }); |
| 1508 | 1887 | } |
| 1509 | 1888 | } |
| 1889 | + | |
| 1510 | 1890 | remove(query) { |
| 1511 | - const queryInMap = this.#queries.get(query.queryHash); | |
| 1891 | + const queryInMap = this.queriesMap[query.queryHash]; | |
| 1892 | + | |
| 1512 | 1893 | if (queryInMap) { |
| 1513 | 1894 | query.destroy(); |
| 1895 | + this.queries = this.queries.filter(x => x !== query); | |
| 1896 | + | |
| 1514 | 1897 | if (queryInMap === query) { |
| 1515 | - this.#queries.delete(query.queryHash); | |
| 1898 | + delete this.queriesMap[query.queryHash]; | |
| 1516 | 1899 | } |
| 1517 | - this.notify({ type: "removed", query }); | |
| 1900 | + | |
| 1901 | + this.notify({ | |
| 1902 | + type: 'removed', | |
| 1903 | + query | |
| 1904 | + }); | |
| 1518 | 1905 | } |
| 1519 | 1906 | } |
| 1907 | + | |
| 1520 | 1908 | clear() { |
| 1521 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { | |
| 1522 | - this.getAll().forEach((query) => { | |
| 1909 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { | |
| 1910 | + this.queries.forEach(query => { | |
| 1523 | 1911 | this.remove(query); |
| 1524 | 1912 | }); |
| 1525 | 1913 | }); |
| 1526 | 1914 | } |
| 1915 | + | |
| 1527 | 1916 | get(queryHash) { |
| 1528 | - return this.#queries.get(queryHash); | |
| 1917 | + return this.queriesMap[queryHash]; | |
| 1529 | 1918 | } |
| 1919 | + | |
| 1530 | 1920 | getAll() { |
| 1531 | - return [...this.#queries.values()]; | |
| 1921 | + return this.queries; | |
| 1532 | 1922 | } |
| 1533 | - find(filters) { | |
| 1534 | - const defaultedFilters = { exact: true, ...filters }; | |
| 1535 | - return this.getAll().find( | |
| 1536 | - (query) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.matchQuery)(defaultedFilters, query) | |
| 1537 | - ); | |
| 1923 | + | |
| 1924 | + find(arg1, arg2) { | |
| 1925 | + const [filters] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.parseFilterArgs)(arg1, arg2); | |
| 1926 | + | |
| 1927 | + if (typeof filters.exact === 'undefined') { | |
| 1928 | + filters.exact = true; | |
| 1929 | + } | |
| 1930 | + | |
| 1931 | + return this.queries.find(query => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.matchQuery)(filters, query)); | |
| 1538 | 1932 | } |
| 1539 | - findAll(filters = {}) { | |
| 1540 | - const queries = this.getAll(); | |
| 1541 | - return Object.keys(filters).length > 0 ? queries.filter((query) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.matchQuery)(filters, query)) : queries; | |
| 1933 | + | |
| 1934 | + findAll(arg1, arg2) { | |
| 1935 | + const [filters] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.parseFilterArgs)(arg1, arg2); | |
| 1936 | + return Object.keys(filters).length > 0 ? this.queries.filter(query => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.matchQuery)(filters, query)) : this.queries; | |
| 1542 | 1937 | } |
| 1938 | + | |
| 1543 | 1939 | notify(event) { |
| 1544 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { | |
| 1545 | - this.listeners.forEach((listener) => { | |
| 1940 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { | |
| 1941 | + this.listeners.forEach(({ | |
| 1942 | + listener | |
| 1943 | + }) => { | |
| 1546 | 1944 | listener(event); |
| 1547 | 1945 | }); |
| 1548 | 1946 | }); |
| 1549 | 1947 | } |
| 1948 | + | |
| 1550 | 1949 | onFocus() { |
| 1551 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { | |
| 1552 | - this.getAll().forEach((query) => { | |
| 1950 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { | |
| 1951 | + this.queries.forEach(query => { | |
| 1553 | 1952 | query.onFocus(); |
| 1554 | 1953 | }); |
| 1555 | 1954 | }); |
| 1556 | 1955 | } |
| 1956 | + | |
| 1557 | 1957 | onOnline() { |
| 1558 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { | |
| 1559 | - this.getAll().forEach((query) => { | |
| 1958 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { | |
| 1959 | + this.queries.forEach(query => { | |
| 1560 | 1960 | query.onOnline(); |
| 1561 | 1961 | }); |
| 1562 | 1962 | }); |
| 1563 | 1963 | } |
| 1564 | -}; | |
| 1565 | 1964 | |
| 1566 | -//# sourceMappingURL=queryCache.js.map | |
| 1965 | +} | |
| 1567 | 1966 | |
| 1967 | + | |
| 1968 | +//# sourceMappingURL=queryCache.mjs.map | |
| 1969 | + | |
| 1970 | + | |
| 1568 | 1971 | /***/ }), |
| 1569 | 1972 | |
| 1570 | -/***/ "./node_modules/@tanstack/query-core/build/modern/queryClient.js": | |
| 1571 | -/*!***********************************************************************!*\ | |
| 1572 | - !*** ./node_modules/@tanstack/query-core/build/modern/queryClient.js ***! | |
| 1573 | - \***********************************************************************/ | |
| 1973 | +/***/ "./node_modules/@tanstack/query-core/build/lib/queryClient.mjs": | |
| 1974 | +/*!*********************************************************************!*\ | |
| 1975 | + !*** ./node_modules/@tanstack/query-core/build/lib/queryClient.mjs ***! | |
| 1976 | + \*********************************************************************/ | |
| 1574 | 1977 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1575 | 1978 | |
| 1576 | 1979 | __webpack_require__.r(__webpack_exports__); |
| 1577 | 1980 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -1576,16 +1979,16 @@ | ||
| 1576 | 1979 | __webpack_require__.r(__webpack_exports__); |
| 1577 | 1980 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1578 | 1981 | /* harmony export */ QueryClient: function() { return /* binding */ QueryClient; } |
| 1579 | 1982 | /* harmony export */ }); |
| 1580 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 1581 | -/* harmony import */ var _queryCache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./queryCache.js */ "./node_modules/@tanstack/query-core/build/modern/queryCache.js"); | |
| 1582 | -/* harmony import */ var _mutationCache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mutationCache.js */ "./node_modules/@tanstack/query-core/build/modern/mutationCache.js"); | |
| 1583 | -/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); | |
| 1584 | -/* harmony import */ var _onlineManager_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./onlineManager.js */ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js"); | |
| 1585 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 1586 | -/* harmony import */ var _infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./infiniteQueryBehavior.js */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js"); | |
| 1587 | -// src/queryClient.ts | |
| 1983 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 1984 | +/* harmony import */ var _queryCache_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./queryCache.mjs */ "./node_modules/@tanstack/query-core/build/lib/queryCache.mjs"); | |
| 1985 | +/* harmony import */ var _mutationCache_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutationCache.mjs */ "./node_modules/@tanstack/query-core/build/lib/mutationCache.mjs"); | |
| 1986 | +/* harmony import */ var _focusManager_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./focusManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/focusManager.mjs"); | |
| 1987 | +/* harmony import */ var _onlineManager_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./onlineManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/onlineManager.mjs"); | |
| 1988 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 1989 | +/* harmony import */ var _infiniteQueryBehavior_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./infiniteQueryBehavior.mjs */ "./node_modules/@tanstack/query-core/build/lib/infiniteQueryBehavior.mjs"); | |
| 1990 | +/* harmony import */ var _logger_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./logger.mjs */ "./node_modules/@tanstack/query-core/build/lib/logger.mjs"); | |
| 1588 | 1991 | |
| 1589 | 1992 | |
| 1590 | 1993 | |
| 1591 | 1994 | |
| @@ -1591,302 +1994,365 @@ | ||
| 1591 | 1994 | |
| 1592 | 1995 | |
| 1593 | 1996 | |
| 1594 | 1997 | |
| 1595 | -var QueryClient = class { | |
| 1596 | - #queryCache; | |
| 1597 | - #mutationCache; | |
| 1598 | - #defaultOptions; | |
| 1599 | - #queryDefaults; | |
| 1600 | - #mutationDefaults; | |
| 1601 | - #mountCount; | |
| 1602 | - #unsubscribeFocus; | |
| 1603 | - #unsubscribeOnline; | |
| 1998 | + | |
| 1999 | + | |
| 2000 | +// CLASS | |
| 2001 | +class QueryClient { | |
| 1604 | 2002 | constructor(config = {}) { |
| 1605 | - this.#queryCache = config.queryCache || new _queryCache_js__WEBPACK_IMPORTED_MODULE_1__.QueryCache(); | |
| 1606 | - this.#mutationCache = config.mutationCache || new _mutationCache_js__WEBPACK_IMPORTED_MODULE_2__.MutationCache(); | |
| 1607 | - this.#defaultOptions = config.defaultOptions || {}; | |
| 1608 | - this.#queryDefaults = /* @__PURE__ */ new Map(); | |
| 1609 | - this.#mutationDefaults = /* @__PURE__ */ new Map(); | |
| 1610 | - this.#mountCount = 0; | |
| 2003 | + this.queryCache = config.queryCache || new _queryCache_mjs__WEBPACK_IMPORTED_MODULE_0__.QueryCache(); | |
| 2004 | + this.mutationCache = config.mutationCache || new _mutationCache_mjs__WEBPACK_IMPORTED_MODULE_1__.MutationCache(); | |
| 2005 | + this.logger = config.logger || _logger_mjs__WEBPACK_IMPORTED_MODULE_2__.defaultLogger; | |
| 2006 | + this.defaultOptions = config.defaultOptions || {}; | |
| 2007 | + this.queryDefaults = []; | |
| 2008 | + this.mutationDefaults = []; | |
| 2009 | + this.mountCount = 0; | |
| 2010 | + | |
| 2011 | + if ( true && config.logger) { | |
| 2012 | + this.logger.error("Passing a custom logger has been deprecated and will be removed in the next major version."); | |
| 2013 | + } | |
| 1611 | 2014 | } |
| 2015 | + | |
| 1612 | 2016 | mount() { |
| 1613 | - this.#mountCount++; | |
| 1614 | - if (this.#mountCount !== 1) return; | |
| 1615 | - this.#unsubscribeFocus = _focusManager_js__WEBPACK_IMPORTED_MODULE_3__.focusManager.subscribe(async (focused) => { | |
| 1616 | - if (focused) { | |
| 1617 | - await this.resumePausedMutations(); | |
| 1618 | - this.#queryCache.onFocus(); | |
| 2017 | + this.mountCount++; | |
| 2018 | + if (this.mountCount !== 1) return; | |
| 2019 | + this.unsubscribeFocus = _focusManager_mjs__WEBPACK_IMPORTED_MODULE_3__.focusManager.subscribe(() => { | |
| 2020 | + if (_focusManager_mjs__WEBPACK_IMPORTED_MODULE_3__.focusManager.isFocused()) { | |
| 2021 | + this.resumePausedMutations(); | |
| 2022 | + this.queryCache.onFocus(); | |
| 1619 | 2023 | } |
| 1620 | 2024 | }); |
| 1621 | - this.#unsubscribeOnline = _onlineManager_js__WEBPACK_IMPORTED_MODULE_4__.onlineManager.subscribe(async (online) => { | |
| 1622 | - if (online) { | |
| 1623 | - await this.resumePausedMutations(); | |
| 1624 | - this.#queryCache.onOnline(); | |
| 2025 | + this.unsubscribeOnline = _onlineManager_mjs__WEBPACK_IMPORTED_MODULE_4__.onlineManager.subscribe(() => { | |
| 2026 | + if (_onlineManager_mjs__WEBPACK_IMPORTED_MODULE_4__.onlineManager.isOnline()) { | |
| 2027 | + this.resumePausedMutations(); | |
| 2028 | + this.queryCache.onOnline(); | |
| 1625 | 2029 | } |
| 1626 | 2030 | }); |
| 1627 | 2031 | } |
| 2032 | + | |
| 1628 | 2033 | unmount() { |
| 1629 | - this.#mountCount--; | |
| 1630 | - if (this.#mountCount !== 0) return; | |
| 1631 | - this.#unsubscribeFocus?.(); | |
| 1632 | - this.#unsubscribeFocus = void 0; | |
| 1633 | - this.#unsubscribeOnline?.(); | |
| 1634 | - this.#unsubscribeOnline = void 0; | |
| 2034 | + var _this$unsubscribeFocu, _this$unsubscribeOnli; | |
| 2035 | + | |
| 2036 | + this.mountCount--; | |
| 2037 | + if (this.mountCount !== 0) return; | |
| 2038 | + (_this$unsubscribeFocu = this.unsubscribeFocus) == null ? void 0 : _this$unsubscribeFocu.call(this); | |
| 2039 | + this.unsubscribeFocus = undefined; | |
| 2040 | + (_this$unsubscribeOnli = this.unsubscribeOnline) == null ? void 0 : _this$unsubscribeOnli.call(this); | |
| 2041 | + this.unsubscribeOnline = undefined; | |
| 1635 | 2042 | } |
| 1636 | - isFetching(filters) { | |
| 1637 | - return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length; | |
| 2043 | + | |
| 2044 | + isFetching(arg1, arg2) { | |
| 2045 | + const [filters] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2); | |
| 2046 | + filters.fetchStatus = 'fetching'; | |
| 2047 | + return this.queryCache.findAll(filters).length; | |
| 1638 | 2048 | } |
| 2049 | + | |
| 1639 | 2050 | isMutating(filters) { |
| 1640 | - return this.#mutationCache.findAll({ ...filters, status: "pending" }).length; | |
| 2051 | + return this.mutationCache.findAll({ ...filters, | |
| 2052 | + fetching: true | |
| 2053 | + }).length; | |
| 1641 | 2054 | } |
| 1642 | - /** | |
| 1643 | - * Imperative (non-reactive) way to retrieve data for a QueryKey. | |
| 1644 | - * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. | |
| 1645 | - * | |
| 1646 | - * Hint: Do not use this function inside a component, because it won't receive updates. | |
| 1647 | - * Use `useQuery` to create a `QueryObserver` that subscribes to changes. | |
| 1648 | - */ | |
| 1649 | - getQueryData(queryKey) { | |
| 1650 | - const options = this.defaultQueryOptions({ queryKey }); | |
| 1651 | - return this.#queryCache.get(options.queryHash)?.state.data; | |
| 2055 | + | |
| 2056 | + getQueryData(queryKey, filters) { | |
| 2057 | + var _this$queryCache$find; | |
| 2058 | + | |
| 2059 | + return (_this$queryCache$find = this.queryCache.find(queryKey, filters)) == null ? void 0 : _this$queryCache$find.state.data; | |
| 1652 | 2060 | } |
| 1653 | - ensureQueryData(options) { | |
| 1654 | - const defaultedOptions = this.defaultQueryOptions(options); | |
| 1655 | - const query = this.#queryCache.build(this, defaultedOptions); | |
| 1656 | - const cachedData = query.state.data; | |
| 1657 | - if (cachedData === void 0) { | |
| 1658 | - return this.fetchQuery(options); | |
| 1659 | - } | |
| 1660 | - if (options.revalidateIfStale && query.isStaleByTime((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveStaleTime)(defaultedOptions.staleTime, query))) { | |
| 1661 | - void this.prefetchQuery(defaultedOptions); | |
| 1662 | - } | |
| 1663 | - return Promise.resolve(cachedData); | |
| 2061 | + | |
| 2062 | + ensureQueryData(arg1, arg2, arg3) { | |
| 2063 | + const parsedOptions = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(arg1, arg2, arg3); | |
| 2064 | + const cachedData = this.getQueryData(parsedOptions.queryKey); | |
| 2065 | + return cachedData ? Promise.resolve(cachedData) : this.fetchQuery(parsedOptions); | |
| 1664 | 2066 | } |
| 1665 | - getQueriesData(filters) { | |
| 1666 | - return this.#queryCache.findAll(filters).map(({ queryKey, state }) => { | |
| 2067 | + | |
| 2068 | + getQueriesData(queryKeyOrFilters) { | |
| 2069 | + return this.getQueryCache().findAll(queryKeyOrFilters).map(({ | |
| 2070 | + queryKey, | |
| 2071 | + state | |
| 2072 | + }) => { | |
| 1667 | 2073 | const data = state.data; |
| 1668 | 2074 | return [queryKey, data]; |
| 1669 | 2075 | }); |
| 1670 | 2076 | } |
| 2077 | + | |
| 1671 | 2078 | setQueryData(queryKey, updater, options) { |
| 1672 | - const defaultedOptions = this.defaultQueryOptions({ queryKey }); | |
| 1673 | - const query = this.#queryCache.get( | |
| 1674 | - defaultedOptions.queryHash | |
| 1675 | - ); | |
| 1676 | - const prevData = query?.state.data; | |
| 1677 | - const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.functionalUpdate)(updater, prevData); | |
| 1678 | - if (data === void 0) { | |
| 1679 | - return void 0; | |
| 2079 | + const query = this.queryCache.find(queryKey); | |
| 2080 | + const prevData = query == null ? void 0 : query.state.data; | |
| 2081 | + const data = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.functionalUpdate)(updater, prevData); | |
| 2082 | + | |
| 2083 | + if (typeof data === 'undefined') { | |
| 2084 | + return undefined; | |
| 1680 | 2085 | } |
| 1681 | - return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true }); | |
| 2086 | + | |
| 2087 | + const parsedOptions = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(queryKey); | |
| 2088 | + const defaultedOptions = this.defaultQueryOptions(parsedOptions); | |
| 2089 | + return this.queryCache.build(this, defaultedOptions).setData(data, { ...options, | |
| 2090 | + manual: true | |
| 2091 | + }); | |
| 1682 | 2092 | } |
| 1683 | - setQueriesData(filters, updater, options) { | |
| 1684 | - return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( | |
| 1685 | - () => this.#queryCache.findAll(filters).map(({ queryKey }) => [ | |
| 1686 | - queryKey, | |
| 1687 | - this.setQueryData(queryKey, updater, options) | |
| 1688 | - ]) | |
| 1689 | - ); | |
| 2093 | + | |
| 2094 | + setQueriesData(queryKeyOrFilters, updater, options) { | |
| 2095 | + return _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(() => this.getQueryCache().findAll(queryKeyOrFilters).map(({ | |
| 2096 | + queryKey | |
| 2097 | + }) => [queryKey, this.setQueryData(queryKey, updater, options)])); | |
| 1690 | 2098 | } |
| 1691 | - getQueryState(queryKey) { | |
| 1692 | - const options = this.defaultQueryOptions({ queryKey }); | |
| 1693 | - return this.#queryCache.get( | |
| 1694 | - options.queryHash | |
| 1695 | - )?.state; | |
| 2099 | + | |
| 2100 | + getQueryState(queryKey, filters) { | |
| 2101 | + var _this$queryCache$find2; | |
| 2102 | + | |
| 2103 | + return (_this$queryCache$find2 = this.queryCache.find(queryKey, filters)) == null ? void 0 : _this$queryCache$find2.state; | |
| 1696 | 2104 | } |
| 1697 | - removeQueries(filters) { | |
| 1698 | - const queryCache = this.#queryCache; | |
| 1699 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { | |
| 1700 | - queryCache.findAll(filters).forEach((query) => { | |
| 2105 | + | |
| 2106 | + removeQueries(arg1, arg2) { | |
| 2107 | + const [filters] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2); | |
| 2108 | + const queryCache = this.queryCache; | |
| 2109 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(() => { | |
| 2110 | + queryCache.findAll(filters).forEach(query => { | |
| 1701 | 2111 | queryCache.remove(query); |
| 1702 | 2112 | }); |
| 1703 | 2113 | }); |
| 1704 | 2114 | } |
| 1705 | - resetQueries(filters, options) { | |
| 1706 | - const queryCache = this.#queryCache; | |
| 1707 | - return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { | |
| 1708 | - queryCache.findAll(filters).forEach((query) => { | |
| 2115 | + | |
| 2116 | + resetQueries(arg1, arg2, arg3) { | |
| 2117 | + const [filters, options] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3); | |
| 2118 | + const queryCache = this.queryCache; | |
| 2119 | + const refetchFilters = { | |
| 2120 | + type: 'active', | |
| 2121 | + ...filters | |
| 2122 | + }; | |
| 2123 | + return _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(() => { | |
| 2124 | + queryCache.findAll(filters).forEach(query => { | |
| 1709 | 2125 | query.reset(); |
| 1710 | 2126 | }); |
| 1711 | - return this.refetchQueries( | |
| 1712 | - { | |
| 1713 | - type: "active", | |
| 1714 | - ...filters | |
| 1715 | - }, | |
| 1716 | - options | |
| 1717 | - ); | |
| 2127 | + return this.refetchQueries(refetchFilters, options); | |
| 1718 | 2128 | }); |
| 1719 | 2129 | } |
| 1720 | - cancelQueries(filters, cancelOptions = {}) { | |
| 1721 | - const defaultedCancelOptions = { revert: true, ...cancelOptions }; | |
| 1722 | - const promises = _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( | |
| 1723 | - () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)) | |
| 1724 | - ); | |
| 1725 | - return Promise.all(promises).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); | |
| 2130 | + | |
| 2131 | + cancelQueries(arg1, arg2, arg3) { | |
| 2132 | + const [filters, cancelOptions = {}] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3); | |
| 2133 | + | |
| 2134 | + if (typeof cancelOptions.revert === 'undefined') { | |
| 2135 | + cancelOptions.revert = true; | |
| 2136 | + } | |
| 2137 | + | |
| 2138 | + const promises = _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(() => this.queryCache.findAll(filters).map(query => query.cancel(cancelOptions))); | |
| 2139 | + return Promise.all(promises).then(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop); | |
| 1726 | 2140 | } |
| 1727 | - invalidateQueries(filters, options = {}) { | |
| 1728 | - return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { | |
| 1729 | - this.#queryCache.findAll(filters).forEach((query) => { | |
| 2141 | + | |
| 2142 | + invalidateQueries(arg1, arg2, arg3) { | |
| 2143 | + const [filters, options] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3); | |
| 2144 | + return _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(() => { | |
| 2145 | + var _ref, _filters$refetchType; | |
| 2146 | + | |
| 2147 | + this.queryCache.findAll(filters).forEach(query => { | |
| 1730 | 2148 | query.invalidate(); |
| 1731 | 2149 | }); |
| 1732 | - if (filters?.refetchType === "none") { | |
| 2150 | + | |
| 2151 | + if (filters.refetchType === 'none') { | |
| 1733 | 2152 | return Promise.resolve(); |
| 1734 | 2153 | } |
| 1735 | - return this.refetchQueries( | |
| 1736 | - { | |
| 1737 | - ...filters, | |
| 1738 | - type: filters?.refetchType ?? filters?.type ?? "active" | |
| 1739 | - }, | |
| 1740 | - options | |
| 1741 | - ); | |
| 2154 | + | |
| 2155 | + const refetchFilters = { ...filters, | |
| 2156 | + type: (_ref = (_filters$refetchType = filters.refetchType) != null ? _filters$refetchType : filters.type) != null ? _ref : 'active' | |
| 2157 | + }; | |
| 2158 | + return this.refetchQueries(refetchFilters, options); | |
| 1742 | 2159 | }); |
| 1743 | 2160 | } |
| 1744 | - refetchQueries(filters, options = {}) { | |
| 1745 | - const fetchOptions = { | |
| 1746 | - ...options, | |
| 1747 | - cancelRefetch: options.cancelRefetch ?? true | |
| 1748 | - }; | |
| 1749 | - const promises = _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( | |
| 1750 | - () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => { | |
| 1751 | - let promise = query.fetch(void 0, fetchOptions); | |
| 1752 | - if (!fetchOptions.throwOnError) { | |
| 1753 | - promise = promise.catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); | |
| 2161 | + | |
| 2162 | + refetchQueries(arg1, arg2, arg3) { | |
| 2163 | + const [filters, options] = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseFilterArgs)(arg1, arg2, arg3); | |
| 2164 | + const promises = _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batch(() => this.queryCache.findAll(filters).filter(query => !query.isDisabled()).map(query => { | |
| 2165 | + var _options$cancelRefetc; | |
| 2166 | + | |
| 2167 | + return query.fetch(undefined, { ...options, | |
| 2168 | + cancelRefetch: (_options$cancelRefetc = options == null ? void 0 : options.cancelRefetch) != null ? _options$cancelRefetc : true, | |
| 2169 | + meta: { | |
| 2170 | + refetchPage: filters.refetchPage | |
| 1754 | 2171 | } |
| 1755 | - return query.state.fetchStatus === "paused" ? Promise.resolve() : promise; | |
| 1756 | - }) | |
| 1757 | - ); | |
| 1758 | - return Promise.all(promises).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); | |
| 2172 | + }); | |
| 2173 | + })); | |
| 2174 | + let promise = Promise.all(promises).then(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop); | |
| 2175 | + | |
| 2176 | + if (!(options != null && options.throwOnError)) { | |
| 2177 | + promise = promise.catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop); | |
| 2178 | + } | |
| 2179 | + | |
| 2180 | + return promise; | |
| 1759 | 2181 | } |
| 1760 | - fetchQuery(options) { | |
| 1761 | - const defaultedOptions = this.defaultQueryOptions(options); | |
| 1762 | - if (defaultedOptions.retry === void 0) { | |
| 2182 | + | |
| 2183 | + fetchQuery(arg1, arg2, arg3) { | |
| 2184 | + const parsedOptions = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(arg1, arg2, arg3); | |
| 2185 | + const defaultedOptions = this.defaultQueryOptions(parsedOptions); // https://github.com/tannerlinsley/react-query/issues/652 | |
| 2186 | + | |
| 2187 | + if (typeof defaultedOptions.retry === 'undefined') { | |
| 1763 | 2188 | defaultedOptions.retry = false; |
| 1764 | 2189 | } |
| 1765 | - const query = this.#queryCache.build(this, defaultedOptions); | |
| 1766 | - return query.isStaleByTime( | |
| 1767 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveStaleTime)(defaultedOptions.staleTime, query) | |
| 1768 | - ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); | |
| 2190 | + | |
| 2191 | + const query = this.queryCache.build(this, defaultedOptions); | |
| 2192 | + return query.isStaleByTime(defaultedOptions.staleTime) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); | |
| 1769 | 2193 | } |
| 1770 | - prefetchQuery(options) { | |
| 1771 | - return this.fetchQuery(options).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); | |
| 2194 | + | |
| 2195 | + prefetchQuery(arg1, arg2, arg3) { | |
| 2196 | + return this.fetchQuery(arg1, arg2, arg3).then(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop); | |
| 1772 | 2197 | } |
| 1773 | - fetchInfiniteQuery(options) { | |
| 1774 | - options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__.infiniteQueryBehavior)(options.pages); | |
| 1775 | - return this.fetchQuery(options); | |
| 2198 | + | |
| 2199 | + fetchInfiniteQuery(arg1, arg2, arg3) { | |
| 2200 | + const parsedOptions = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.parseQueryArgs)(arg1, arg2, arg3); | |
| 2201 | + parsedOptions.behavior = (0,_infiniteQueryBehavior_mjs__WEBPACK_IMPORTED_MODULE_7__.infiniteQueryBehavior)(); | |
| 2202 | + return this.fetchQuery(parsedOptions); | |
| 1776 | 2203 | } |
| 1777 | - prefetchInfiniteQuery(options) { | |
| 1778 | - return this.fetchInfiniteQuery(options).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); | |
| 2204 | + | |
| 2205 | + prefetchInfiniteQuery(arg1, arg2, arg3) { | |
| 2206 | + return this.fetchInfiniteQuery(arg1, arg2, arg3).then(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop).catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.noop); | |
| 1779 | 2207 | } |
| 1780 | - ensureInfiniteQueryData(options) { | |
| 1781 | - options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__.infiniteQueryBehavior)(options.pages); | |
| 1782 | - return this.ensureQueryData(options); | |
| 1783 | - } | |
| 2208 | + | |
| 1784 | 2209 | resumePausedMutations() { |
| 1785 | - if (_onlineManager_js__WEBPACK_IMPORTED_MODULE_4__.onlineManager.isOnline()) { | |
| 1786 | - return this.#mutationCache.resumePausedMutations(); | |
| 1787 | - } | |
| 1788 | - return Promise.resolve(); | |
| 2210 | + return this.mutationCache.resumePausedMutations(); | |
| 1789 | 2211 | } |
| 2212 | + | |
| 1790 | 2213 | getQueryCache() { |
| 1791 | - return this.#queryCache; | |
| 2214 | + return this.queryCache; | |
| 1792 | 2215 | } |
| 2216 | + | |
| 1793 | 2217 | getMutationCache() { |
| 1794 | - return this.#mutationCache; | |
| 2218 | + return this.mutationCache; | |
| 1795 | 2219 | } |
| 2220 | + | |
| 2221 | + getLogger() { | |
| 2222 | + return this.logger; | |
| 2223 | + } | |
| 2224 | + | |
| 1796 | 2225 | getDefaultOptions() { |
| 1797 | - return this.#defaultOptions; | |
| 2226 | + return this.defaultOptions; | |
| 1798 | 2227 | } |
| 2228 | + | |
| 1799 | 2229 | setDefaultOptions(options) { |
| 1800 | - this.#defaultOptions = options; | |
| 2230 | + this.defaultOptions = options; | |
| 1801 | 2231 | } |
| 2232 | + | |
| 1802 | 2233 | setQueryDefaults(queryKey, options) { |
| 1803 | - this.#queryDefaults.set((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashKey)(queryKey), { | |
| 1804 | - queryKey, | |
| 1805 | - defaultOptions: options | |
| 1806 | - }); | |
| 2234 | + const result = this.queryDefaults.find(x => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(queryKey) === (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(x.queryKey)); | |
| 2235 | + | |
| 2236 | + if (result) { | |
| 2237 | + result.defaultOptions = options; | |
| 2238 | + } else { | |
| 2239 | + this.queryDefaults.push({ | |
| 2240 | + queryKey, | |
| 2241 | + defaultOptions: options | |
| 2242 | + }); | |
| 2243 | + } | |
| 1807 | 2244 | } |
| 2245 | + | |
| 1808 | 2246 | getQueryDefaults(queryKey) { |
| 1809 | - const defaults = [...this.#queryDefaults.values()]; | |
| 1810 | - const result = {}; | |
| 1811 | - defaults.forEach((queryDefault) => { | |
| 1812 | - if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.partialMatchKey)(queryKey, queryDefault.queryKey)) { | |
| 1813 | - Object.assign(result, queryDefault.defaultOptions); | |
| 2247 | + if (!queryKey) { | |
| 2248 | + return undefined; | |
| 2249 | + } // Get the first matching defaults | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + const firstMatchingDefaults = this.queryDefaults.find(x => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.partialMatchKey)(queryKey, x.queryKey)); // Additional checks and error in dev mode | |
| 2253 | + | |
| 2254 | + if (true) { | |
| 2255 | + // Retrieve all matching defaults for the given key | |
| 2256 | + const matchingDefaults = this.queryDefaults.filter(x => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.partialMatchKey)(queryKey, x.queryKey)); // It is ok not having defaults, but it is error prone to have more than 1 default for a given key | |
| 2257 | + | |
| 2258 | + if (matchingDefaults.length > 1) { | |
| 2259 | + this.logger.error("[QueryClient] Several query defaults match with key '" + JSON.stringify(queryKey) + "'. The first matching query defaults are used. Please check how query defaults are registered. Order does matter here. cf. https://react-query.tanstack.com/reference/QueryClient#queryclientsetquerydefaults."); | |
| 1814 | 2260 | } |
| 1815 | - }); | |
| 1816 | - return result; | |
| 2261 | + } | |
| 2262 | + | |
| 2263 | + return firstMatchingDefaults == null ? void 0 : firstMatchingDefaults.defaultOptions; | |
| 1817 | 2264 | } |
| 2265 | + | |
| 1818 | 2266 | setMutationDefaults(mutationKey, options) { |
| 1819 | - this.#mutationDefaults.set((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashKey)(mutationKey), { | |
| 1820 | - mutationKey, | |
| 1821 | - defaultOptions: options | |
| 1822 | - }); | |
| 2267 | + const result = this.mutationDefaults.find(x => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(mutationKey) === (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.hashQueryKey)(x.mutationKey)); | |
| 2268 | + | |
| 2269 | + if (result) { | |
| 2270 | + result.defaultOptions = options; | |
| 2271 | + } else { | |
| 2272 | + this.mutationDefaults.push({ | |
| 2273 | + mutationKey, | |
| 2274 | + defaultOptions: options | |
| 2275 | + }); | |
| 2276 | + } | |
| 1823 | 2277 | } |
| 2278 | + | |
| 1824 | 2279 | getMutationDefaults(mutationKey) { |
| 1825 | - const defaults = [...this.#mutationDefaults.values()]; | |
| 1826 | - const result = {}; | |
| 1827 | - defaults.forEach((queryDefault) => { | |
| 1828 | - if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.partialMatchKey)(mutationKey, queryDefault.mutationKey)) { | |
| 1829 | - Object.assign(result, queryDefault.defaultOptions); | |
| 2280 | + if (!mutationKey) { | |
| 2281 | + return undefined; | |
| 2282 | + } // Get the first matching defaults | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + const firstMatchingDefaults = this.mutationDefaults.find(x => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.partialMatchKey)(mutationKey, x.mutationKey)); // Additional checks and error in dev mode | |
| 2286 | + | |
| 2287 | + if (true) { | |
| 2288 | + // Retrieve all matching defaults for the given key | |
| 2289 | + const matchingDefaults = this.mutationDefaults.filter(x => (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.partialMatchKey)(mutationKey, x.mutationKey)); // It is ok not having defaults, but it is error prone to have more than 1 default for a given key | |
| 2290 | + | |
| 2291 | + if (matchingDefaults.length > 1) { | |
| 2292 | + this.logger.error("[QueryClient] Several mutation defaults match with key '" + JSON.stringify(mutationKey) + "'. The first matching mutation defaults are used. Please check how mutation defaults are registered. Order does matter here. cf. https://react-query.tanstack.com/reference/QueryClient#queryclientsetmutationdefaults."); | |
| 1830 | 2293 | } |
| 1831 | - }); | |
| 1832 | - return result; | |
| 2294 | + } | |
| 2295 | + | |
| 2296 | + return firstMatchingDefaults == null ? void 0 : firstMatchingDefaults.defaultOptions; | |
| 1833 | 2297 | } |
| 2298 | + | |
| 1834 | 2299 | defaultQueryOptions(options) { |
| 1835 | - if (options._defaulted) { | |
| 2300 | + if (options != null && options._defaulted) { | |
| 1836 | 2301 | return options; |
| 1837 | 2302 | } |
| 1838 | - const defaultedOptions = { | |
| 1839 | - ...this.#defaultOptions.queries, | |
| 1840 | - ...this.getQueryDefaults(options.queryKey), | |
| 2303 | + | |
| 2304 | + const defaultedOptions = { ...this.defaultOptions.queries, | |
| 2305 | + ...this.getQueryDefaults(options == null ? void 0 : options.queryKey), | |
| 1841 | 2306 | ...options, |
| 1842 | 2307 | _defaulted: true |
| 1843 | 2308 | }; |
| 1844 | - if (!defaultedOptions.queryHash) { | |
| 1845 | - defaultedOptions.queryHash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashQueryKeyByOptions)( | |
| 1846 | - defaultedOptions.queryKey, | |
| 1847 | - defaultedOptions | |
| 1848 | - ); | |
| 2309 | + | |
| 2310 | + if (!defaultedOptions.queryHash && defaultedOptions.queryKey) { | |
| 2311 | + defaultedOptions.queryHash = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_5__.hashQueryKeyByOptions)(defaultedOptions.queryKey, defaultedOptions); | |
| 2312 | + } // dependent default values | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + if (typeof defaultedOptions.refetchOnReconnect === 'undefined') { | |
| 2316 | + defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== 'always'; | |
| 1849 | 2317 | } |
| 1850 | - if (defaultedOptions.refetchOnReconnect === void 0) { | |
| 1851 | - defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always"; | |
| 2318 | + | |
| 2319 | + if (typeof defaultedOptions.useErrorBoundary === 'undefined') { | |
| 2320 | + defaultedOptions.useErrorBoundary = !!defaultedOptions.suspense; | |
| 1852 | 2321 | } |
| 1853 | - if (defaultedOptions.throwOnError === void 0) { | |
| 1854 | - defaultedOptions.throwOnError = !!defaultedOptions.suspense; | |
| 1855 | - } | |
| 1856 | - if (!defaultedOptions.networkMode && defaultedOptions.persister) { | |
| 1857 | - defaultedOptions.networkMode = "offlineFirst"; | |
| 1858 | - } | |
| 1859 | - if (defaultedOptions.queryFn === _utils_js__WEBPACK_IMPORTED_MODULE_0__.skipToken) { | |
| 1860 | - defaultedOptions.enabled = false; | |
| 1861 | - } | |
| 2322 | + | |
| 1862 | 2323 | return defaultedOptions; |
| 1863 | 2324 | } |
| 2325 | + | |
| 1864 | 2326 | defaultMutationOptions(options) { |
| 1865 | - if (options?._defaulted) { | |
| 2327 | + if (options != null && options._defaulted) { | |
| 1866 | 2328 | return options; |
| 1867 | 2329 | } |
| 1868 | - return { | |
| 1869 | - ...this.#defaultOptions.mutations, | |
| 1870 | - ...options?.mutationKey && this.getMutationDefaults(options.mutationKey), | |
| 2330 | + | |
| 2331 | + return { ...this.defaultOptions.mutations, | |
| 2332 | + ...this.getMutationDefaults(options == null ? void 0 : options.mutationKey), | |
| 1871 | 2333 | ...options, |
| 1872 | 2334 | _defaulted: true |
| 1873 | 2335 | }; |
| 1874 | 2336 | } |
| 2337 | + | |
| 1875 | 2338 | clear() { |
| 1876 | - this.#queryCache.clear(); | |
| 1877 | - this.#mutationCache.clear(); | |
| 2339 | + this.queryCache.clear(); | |
| 2340 | + this.mutationCache.clear(); | |
| 1878 | 2341 | } |
| 1879 | -}; | |
| 1880 | 2342 | |
| 1881 | -//# sourceMappingURL=queryClient.js.map | |
| 2343 | +} | |
| 1882 | 2344 | |
| 2345 | + | |
| 2346 | +//# sourceMappingURL=queryClient.mjs.map | |
| 2347 | + | |
| 2348 | + | |
| 1883 | 2349 | /***/ }), |
| 1884 | 2350 | |
| 1885 | -/***/ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js": | |
| 1886 | -/*!*************************************************************************!*\ | |
| 1887 | - !*** ./node_modules/@tanstack/query-core/build/modern/queryObserver.js ***! | |
| 1888 | - \*************************************************************************/ | |
| 2351 | +/***/ "./node_modules/@tanstack/query-core/build/lib/queryObserver.mjs": | |
| 2352 | +/*!***********************************************************************!*\ | |
| 2353 | + !*** ./node_modules/@tanstack/query-core/build/lib/queryObserver.mjs ***! | |
| 2354 | + \***********************************************************************/ | |
| 1889 | 2355 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1890 | 2356 | |
| 1891 | 2357 | __webpack_require__.r(__webpack_exports__); |
| 1892 | 2358 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -1891,16 +2357,13 @@ | ||
| 1891 | 2357 | __webpack_require__.r(__webpack_exports__); |
| 1892 | 2358 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1893 | 2359 | /* harmony export */ QueryObserver: function() { return /* binding */ QueryObserver; } |
| 1894 | 2360 | /* harmony export */ }); |
| 1895 | -/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); | |
| 1896 | -/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 1897 | -/* harmony import */ var _query_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./query.js */ "./node_modules/@tanstack/query-core/build/modern/query.js"); | |
| 1898 | -/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); | |
| 1899 | -/* harmony import */ var _thenable_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./thenable.js */ "./node_modules/@tanstack/query-core/build/modern/thenable.js"); | |
| 1900 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 1901 | -/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); | |
| 1902 | -// src/queryObserver.ts | |
| 2361 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 2362 | +/* harmony import */ var _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./notifyManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 2363 | +/* harmony import */ var _focusManager_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focusManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/focusManager.mjs"); | |
| 2364 | +/* harmony import */ var _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.mjs */ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs"); | |
| 2365 | +/* harmony import */ var _retryer_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./retryer.mjs */ "./node_modules/@tanstack/query-core/build/lib/retryer.mjs"); | |
| 1903 | 2366 | |
| 1904 | 2367 | |
| 1905 | 2368 | |
| 1906 | 2369 | |
| @@ -1905,467 +2368,590 @@ | ||
| 1905 | 2368 | |
| 1906 | 2369 | |
| 1907 | 2370 | |
| 1908 | 2371 | |
| 1909 | - | |
| 1910 | -var QueryObserver = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_3__.Subscribable { | |
| 2372 | +class QueryObserver extends _subscribable_mjs__WEBPACK_IMPORTED_MODULE_0__.Subscribable { | |
| 1911 | 2373 | constructor(client, options) { |
| 1912 | 2374 | super(); |
| 2375 | + this.client = client; | |
| 1913 | 2376 | this.options = options; |
| 1914 | - this.#client = client; | |
| 1915 | - this.#selectError = null; | |
| 1916 | - this.#currentThenable = (0,_thenable_js__WEBPACK_IMPORTED_MODULE_4__.pendingThenable)(); | |
| 2377 | + this.trackedProps = new Set(); | |
| 2378 | + this.selectError = null; | |
| 1917 | 2379 | this.bindMethods(); |
| 1918 | 2380 | this.setOptions(options); |
| 1919 | 2381 | } |
| 1920 | - #client; | |
| 1921 | - #currentQuery = void 0; | |
| 1922 | - #currentQueryInitialState = void 0; | |
| 1923 | - #currentResult = void 0; | |
| 1924 | - #currentResultState; | |
| 1925 | - #currentResultOptions; | |
| 1926 | - #currentThenable; | |
| 1927 | - #selectError; | |
| 1928 | - #selectFn; | |
| 1929 | - #selectResult; | |
| 1930 | - // This property keeps track of the last query with defined data. | |
| 1931 | - // It will be used to pass the previous data and query to the placeholder function between renders. | |
| 1932 | - #lastQueryWithDefinedData; | |
| 1933 | - #staleTimeoutId; | |
| 1934 | - #refetchIntervalId; | |
| 1935 | - #currentRefetchInterval; | |
| 1936 | - #trackedProps = /* @__PURE__ */ new Set(); | |
| 2382 | + | |
| 1937 | 2383 | bindMethods() { |
| 2384 | + this.remove = this.remove.bind(this); | |
| 1938 | 2385 | this.refetch = this.refetch.bind(this); |
| 1939 | 2386 | } |
| 2387 | + | |
| 1940 | 2388 | onSubscribe() { |
| 1941 | 2389 | if (this.listeners.size === 1) { |
| 1942 | - this.#currentQuery.addObserver(this); | |
| 1943 | - if (shouldFetchOnMount(this.#currentQuery, this.options)) { | |
| 1944 | - this.#executeFetch(); | |
| 1945 | - } else { | |
| 1946 | - this.updateResult(); | |
| 2390 | + this.currentQuery.addObserver(this); | |
| 2391 | + | |
| 2392 | + if (shouldFetchOnMount(this.currentQuery, this.options)) { | |
| 2393 | + this.executeFetch(); | |
| 1947 | 2394 | } |
| 1948 | - this.#updateTimers(); | |
| 2395 | + | |
| 2396 | + this.updateTimers(); | |
| 1949 | 2397 | } |
| 1950 | 2398 | } |
| 2399 | + | |
| 1951 | 2400 | onUnsubscribe() { |
| 1952 | 2401 | if (!this.hasListeners()) { |
| 1953 | 2402 | this.destroy(); |
| 1954 | 2403 | } |
| 1955 | 2404 | } |
| 2405 | + | |
| 1956 | 2406 | shouldFetchOnReconnect() { |
| 1957 | - return shouldFetchOn( | |
| 1958 | - this.#currentQuery, | |
| 1959 | - this.options, | |
| 1960 | - this.options.refetchOnReconnect | |
| 1961 | - ); | |
| 2407 | + return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnReconnect); | |
| 1962 | 2408 | } |
| 2409 | + | |
| 1963 | 2410 | shouldFetchOnWindowFocus() { |
| 1964 | - return shouldFetchOn( | |
| 1965 | - this.#currentQuery, | |
| 1966 | - this.options, | |
| 1967 | - this.options.refetchOnWindowFocus | |
| 1968 | - ); | |
| 2411 | + return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnWindowFocus); | |
| 1969 | 2412 | } |
| 2413 | + | |
| 1970 | 2414 | destroy() { |
| 1971 | - this.listeners = /* @__PURE__ */ new Set(); | |
| 1972 | - this.#clearStaleTimeout(); | |
| 1973 | - this.#clearRefetchInterval(); | |
| 1974 | - this.#currentQuery.removeObserver(this); | |
| 2415 | + this.listeners = new Set(); | |
| 2416 | + this.clearStaleTimeout(); | |
| 2417 | + this.clearRefetchInterval(); | |
| 2418 | + this.currentQuery.removeObserver(this); | |
| 1975 | 2419 | } |
| 1976 | - setOptions(options) { | |
| 2420 | + | |
| 2421 | + setOptions(options, notifyOptions) { | |
| 1977 | 2422 | const prevOptions = this.options; |
| 1978 | - const prevQuery = this.#currentQuery; | |
| 1979 | - this.options = this.#client.defaultQueryOptions(options); | |
| 1980 | - if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) !== "boolean") { | |
| 1981 | - throw new Error( | |
| 1982 | - "Expected enabled to be a boolean or a callback that returns a boolean" | |
| 1983 | - ); | |
| 2423 | + const prevQuery = this.currentQuery; | |
| 2424 | + this.options = this.client.defaultQueryOptions(options); | |
| 2425 | + | |
| 2426 | + if ( true && typeof (options == null ? void 0 : options.isDataEqual) !== 'undefined') { | |
| 2427 | + this.client.getLogger().error("The isDataEqual option has been deprecated and will be removed in the next major version. You can achieve the same functionality by passing a function as the structuralSharing option"); | |
| 1984 | 2428 | } |
| 1985 | - this.#updateQuery(); | |
| 1986 | - this.#currentQuery.setOptions(this.options); | |
| 1987 | - if (prevOptions._defaulted && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.shallowEqualObjects)(this.options, prevOptions)) { | |
| 1988 | - this.#client.getQueryCache().notify({ | |
| 1989 | - type: "observerOptionsUpdated", | |
| 1990 | - query: this.#currentQuery, | |
| 2429 | + | |
| 2430 | + if (!(0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(prevOptions, this.options)) { | |
| 2431 | + this.client.getQueryCache().notify({ | |
| 2432 | + type: 'observerOptionsUpdated', | |
| 2433 | + query: this.currentQuery, | |
| 1991 | 2434 | observer: this |
| 1992 | 2435 | }); |
| 1993 | 2436 | } |
| 1994 | - const mounted = this.hasListeners(); | |
| 1995 | - if (mounted && shouldFetchOptionally( | |
| 1996 | - this.#currentQuery, | |
| 1997 | - prevQuery, | |
| 1998 | - this.options, | |
| 1999 | - prevOptions | |
| 2000 | - )) { | |
| 2001 | - this.#executeFetch(); | |
| 2437 | + | |
| 2438 | + if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') { | |
| 2439 | + throw new Error('Expected enabled to be a boolean'); | |
| 2440 | + } // Keep previous query key if the user does not supply one | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + if (!this.options.queryKey) { | |
| 2444 | + this.options.queryKey = prevOptions.queryKey; | |
| 2002 | 2445 | } |
| 2003 | - this.updateResult(); | |
| 2004 | - if (mounted && (this.#currentQuery !== prevQuery || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(prevOptions.enabled, this.#currentQuery) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(this.options.staleTime, this.#currentQuery) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(prevOptions.staleTime, this.#currentQuery))) { | |
| 2005 | - this.#updateStaleTimeout(); | |
| 2446 | + | |
| 2447 | + this.updateQuery(); | |
| 2448 | + const mounted = this.hasListeners(); // Fetch if there are subscribers | |
| 2449 | + | |
| 2450 | + if (mounted && shouldFetchOptionally(this.currentQuery, prevQuery, this.options, prevOptions)) { | |
| 2451 | + this.executeFetch(); | |
| 2452 | + } // Update result | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + this.updateResult(notifyOptions); // Update stale interval if needed | |
| 2456 | + | |
| 2457 | + if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) { | |
| 2458 | + this.updateStaleTimeout(); | |
| 2006 | 2459 | } |
| 2007 | - const nextRefetchInterval = this.#computeRefetchInterval(); | |
| 2008 | - if (mounted && (this.#currentQuery !== prevQuery || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) { | |
| 2009 | - this.#updateRefetchInterval(nextRefetchInterval); | |
| 2460 | + | |
| 2461 | + const nextRefetchInterval = this.computeRefetchInterval(); // Update refetch interval if needed | |
| 2462 | + | |
| 2463 | + if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.currentRefetchInterval)) { | |
| 2464 | + this.updateRefetchInterval(nextRefetchInterval); | |
| 2010 | 2465 | } |
| 2011 | 2466 | } |
| 2467 | + | |
| 2012 | 2468 | getOptimisticResult(options) { |
| 2013 | - const query = this.#client.getQueryCache().build(this.#client, options); | |
| 2469 | + const query = this.client.getQueryCache().build(this.client, options); | |
| 2014 | 2470 | const result = this.createResult(query, options); |
| 2015 | - if (shouldAssignObserverCurrentProperties(this, result)) { | |
| 2016 | - this.#currentResult = result; | |
| 2017 | - this.#currentResultOptions = this.options; | |
| 2018 | - this.#currentResultState = this.#currentQuery.state; | |
| 2471 | + | |
| 2472 | + if (shouldAssignObserverCurrentProperties(this, result, options)) { | |
| 2473 | + // this assigns the optimistic result to the current Observer | |
| 2474 | + // because if the query function changes, useQuery will be performing | |
| 2475 | + // an effect where it would fetch again. | |
| 2476 | + // When the fetch finishes, we perform a deep data cloning in order | |
| 2477 | + // to reuse objects references. This deep data clone is performed against | |
| 2478 | + // the `observer.currentResult.data` property | |
| 2479 | + // When QueryKey changes, we refresh the query and get new `optimistic` | |
| 2480 | + // result, while we leave the `observer.currentResult`, so when new data | |
| 2481 | + // arrives, it finds the old `observer.currentResult` which is related | |
| 2482 | + // to the old QueryKey. Which means that currentResult and selectData are | |
| 2483 | + // out of sync already. | |
| 2484 | + // To solve this, we move the cursor of the currentResult everytime | |
| 2485 | + // an observer reads an optimistic value. | |
| 2486 | + // When keeping the previous data, the result doesn't change until new | |
| 2487 | + // data arrives. | |
| 2488 | + this.currentResult = result; | |
| 2489 | + this.currentResultOptions = this.options; | |
| 2490 | + this.currentResultState = this.currentQuery.state; | |
| 2019 | 2491 | } |
| 2492 | + | |
| 2020 | 2493 | return result; |
| 2021 | 2494 | } |
| 2495 | + | |
| 2022 | 2496 | getCurrentResult() { |
| 2023 | - return this.#currentResult; | |
| 2497 | + return this.currentResult; | |
| 2024 | 2498 | } |
| 2025 | - trackResult(result, onPropTracked) { | |
| 2026 | - return new Proxy(result, { | |
| 2027 | - get: (target, key) => { | |
| 2028 | - this.trackProp(key); | |
| 2029 | - onPropTracked?.(key); | |
| 2030 | - if (key === "promise") { | |
| 2031 | - this.trackProp("data"); | |
| 2032 | - if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") { | |
| 2033 | - this.#currentThenable.reject( | |
| 2034 | - new Error( | |
| 2035 | - "experimental_prefetchInRender feature flag is not enabled" | |
| 2036 | - ) | |
| 2037 | - ); | |
| 2038 | - } | |
| 2499 | + | |
| 2500 | + trackResult(result) { | |
| 2501 | + const trackedResult = {}; | |
| 2502 | + Object.keys(result).forEach(key => { | |
| 2503 | + Object.defineProperty(trackedResult, key, { | |
| 2504 | + configurable: false, | |
| 2505 | + enumerable: true, | |
| 2506 | + get: () => { | |
| 2507 | + this.trackedProps.add(key); | |
| 2508 | + return result[key]; | |
| 2039 | 2509 | } |
| 2040 | - return Reflect.get(target, key); | |
| 2041 | - } | |
| 2510 | + }); | |
| 2042 | 2511 | }); |
| 2512 | + return trackedResult; | |
| 2043 | 2513 | } |
| 2044 | - trackProp(key) { | |
| 2045 | - this.#trackedProps.add(key); | |
| 2514 | + | |
| 2515 | + getCurrentQuery() { | |
| 2516 | + return this.currentQuery; | |
| 2046 | 2517 | } |
| 2047 | - getCurrentQuery() { | |
| 2048 | - return this.#currentQuery; | |
| 2518 | + | |
| 2519 | + remove() { | |
| 2520 | + this.client.getQueryCache().remove(this.currentQuery); | |
| 2049 | 2521 | } |
| 2050 | - refetch({ ...options } = {}) { | |
| 2051 | - return this.fetch({ | |
| 2052 | - ...options | |
| 2522 | + | |
| 2523 | + refetch({ | |
| 2524 | + refetchPage, | |
| 2525 | + ...options | |
| 2526 | + } = {}) { | |
| 2527 | + return this.fetch({ ...options, | |
| 2528 | + meta: { | |
| 2529 | + refetchPage | |
| 2530 | + } | |
| 2053 | 2531 | }); |
| 2054 | 2532 | } |
| 2533 | + | |
| 2055 | 2534 | fetchOptimistic(options) { |
| 2056 | - const defaultedOptions = this.#client.defaultQueryOptions(options); | |
| 2057 | - const query = this.#client.getQueryCache().build(this.#client, defaultedOptions); | |
| 2535 | + const defaultedOptions = this.client.defaultQueryOptions(options); | |
| 2536 | + const query = this.client.getQueryCache().build(this.client, defaultedOptions); | |
| 2537 | + query.isFetchingOptimistic = true; | |
| 2058 | 2538 | return query.fetch().then(() => this.createResult(query, defaultedOptions)); |
| 2059 | 2539 | } |
| 2540 | + | |
| 2060 | 2541 | fetch(fetchOptions) { |
| 2061 | - return this.#executeFetch({ | |
| 2062 | - ...fetchOptions, | |
| 2063 | - cancelRefetch: fetchOptions.cancelRefetch ?? true | |
| 2542 | + var _fetchOptions$cancelR; | |
| 2543 | + | |
| 2544 | + return this.executeFetch({ ...fetchOptions, | |
| 2545 | + cancelRefetch: (_fetchOptions$cancelR = fetchOptions.cancelRefetch) != null ? _fetchOptions$cancelR : true | |
| 2064 | 2546 | }).then(() => { |
| 2065 | 2547 | this.updateResult(); |
| 2066 | - return this.#currentResult; | |
| 2548 | + return this.currentResult; | |
| 2067 | 2549 | }); |
| 2068 | 2550 | } |
| 2069 | - #executeFetch(fetchOptions) { | |
| 2070 | - this.#updateQuery(); | |
| 2071 | - let promise = this.#currentQuery.fetch( | |
| 2072 | - this.options, | |
| 2073 | - fetchOptions | |
| 2074 | - ); | |
| 2075 | - if (!fetchOptions?.throwOnError) { | |
| 2076 | - promise = promise.catch(_utils_js__WEBPACK_IMPORTED_MODULE_5__.noop); | |
| 2551 | + | |
| 2552 | + executeFetch(fetchOptions) { | |
| 2553 | + // Make sure we reference the latest query as the current one might have been removed | |
| 2554 | + this.updateQuery(); // Fetch | |
| 2555 | + | |
| 2556 | + let promise = this.currentQuery.fetch(this.options, fetchOptions); | |
| 2557 | + | |
| 2558 | + if (!(fetchOptions != null && fetchOptions.throwOnError)) { | |
| 2559 | + promise = promise.catch(_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.noop); | |
| 2077 | 2560 | } |
| 2561 | + | |
| 2078 | 2562 | return promise; |
| 2079 | 2563 | } |
| 2080 | - #updateStaleTimeout() { | |
| 2081 | - this.#clearStaleTimeout(); | |
| 2082 | - const staleTime = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)( | |
| 2083 | - this.options.staleTime, | |
| 2084 | - this.#currentQuery | |
| 2085 | - ); | |
| 2086 | - if (_utils_js__WEBPACK_IMPORTED_MODULE_5__.isServer || this.#currentResult.isStale || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.isValidTimeout)(staleTime)) { | |
| 2564 | + | |
| 2565 | + updateStaleTimeout() { | |
| 2566 | + this.clearStaleTimeout(); | |
| 2567 | + | |
| 2568 | + if (_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.isServer || this.currentResult.isStale || !(0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.options.staleTime)) { | |
| 2087 | 2569 | return; |
| 2088 | 2570 | } |
| 2089 | - const time = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.timeUntilStale)(this.#currentResult.dataUpdatedAt, staleTime); | |
| 2571 | + | |
| 2572 | + const time = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.timeUntilStale)(this.currentResult.dataUpdatedAt, this.options.staleTime); // The timeout is sometimes triggered 1 ms before the stale time expiration. | |
| 2573 | + // To mitigate this issue we always add 1 ms to the timeout. | |
| 2574 | + | |
| 2090 | 2575 | const timeout = time + 1; |
| 2091 | - this.#staleTimeoutId = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.setTimeout(() => { | |
| 2092 | - if (!this.#currentResult.isStale) { | |
| 2576 | + this.staleTimeoutId = setTimeout(() => { | |
| 2577 | + if (!this.currentResult.isStale) { | |
| 2093 | 2578 | this.updateResult(); |
| 2094 | 2579 | } |
| 2095 | 2580 | }, timeout); |
| 2096 | 2581 | } |
| 2097 | - #computeRefetchInterval() { | |
| 2098 | - return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false; | |
| 2582 | + | |
| 2583 | + computeRefetchInterval() { | |
| 2584 | + var _this$options$refetch; | |
| 2585 | + | |
| 2586 | + return typeof this.options.refetchInterval === 'function' ? this.options.refetchInterval(this.currentResult.data, this.currentQuery) : (_this$options$refetch = this.options.refetchInterval) != null ? _this$options$refetch : false; | |
| 2099 | 2587 | } |
| 2100 | - #updateRefetchInterval(nextInterval) { | |
| 2101 | - this.#clearRefetchInterval(); | |
| 2102 | - this.#currentRefetchInterval = nextInterval; | |
| 2103 | - if (_utils_js__WEBPACK_IMPORTED_MODULE_5__.isServer || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) === false || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.isValidTimeout)(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) { | |
| 2588 | + | |
| 2589 | + updateRefetchInterval(nextInterval) { | |
| 2590 | + this.clearRefetchInterval(); | |
| 2591 | + this.currentRefetchInterval = nextInterval; | |
| 2592 | + | |
| 2593 | + if (_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.isServer || this.options.enabled === false || !(0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.currentRefetchInterval) || this.currentRefetchInterval === 0) { | |
| 2104 | 2594 | return; |
| 2105 | 2595 | } |
| 2106 | - this.#refetchIntervalId = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.setInterval(() => { | |
| 2107 | - if (this.options.refetchIntervalInBackground || _focusManager_js__WEBPACK_IMPORTED_MODULE_0__.focusManager.isFocused()) { | |
| 2108 | - this.#executeFetch(); | |
| 2596 | + | |
| 2597 | + this.refetchIntervalId = setInterval(() => { | |
| 2598 | + if (this.options.refetchIntervalInBackground || _focusManager_mjs__WEBPACK_IMPORTED_MODULE_2__.focusManager.isFocused()) { | |
| 2599 | + this.executeFetch(); | |
| 2109 | 2600 | } |
| 2110 | - }, this.#currentRefetchInterval); | |
| 2601 | + }, this.currentRefetchInterval); | |
| 2111 | 2602 | } |
| 2112 | - #updateTimers() { | |
| 2113 | - this.#updateStaleTimeout(); | |
| 2114 | - this.#updateRefetchInterval(this.#computeRefetchInterval()); | |
| 2603 | + | |
| 2604 | + updateTimers() { | |
| 2605 | + this.updateStaleTimeout(); | |
| 2606 | + this.updateRefetchInterval(this.computeRefetchInterval()); | |
| 2115 | 2607 | } |
| 2116 | - #clearStaleTimeout() { | |
| 2117 | - if (this.#staleTimeoutId) { | |
| 2118 | - _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.clearTimeout(this.#staleTimeoutId); | |
| 2119 | - this.#staleTimeoutId = void 0; | |
| 2608 | + | |
| 2609 | + clearStaleTimeout() { | |
| 2610 | + if (this.staleTimeoutId) { | |
| 2611 | + clearTimeout(this.staleTimeoutId); | |
| 2612 | + this.staleTimeoutId = undefined; | |
| 2120 | 2613 | } |
| 2121 | 2614 | } |
| 2122 | - #clearRefetchInterval() { | |
| 2123 | - if (this.#refetchIntervalId) { | |
| 2124 | - _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.clearInterval(this.#refetchIntervalId); | |
| 2125 | - this.#refetchIntervalId = void 0; | |
| 2615 | + | |
| 2616 | + clearRefetchInterval() { | |
| 2617 | + if (this.refetchIntervalId) { | |
| 2618 | + clearInterval(this.refetchIntervalId); | |
| 2619 | + this.refetchIntervalId = undefined; | |
| 2126 | 2620 | } |
| 2127 | 2621 | } |
| 2622 | + | |
| 2128 | 2623 | createResult(query, options) { |
| 2129 | - const prevQuery = this.#currentQuery; | |
| 2624 | + const prevQuery = this.currentQuery; | |
| 2130 | 2625 | const prevOptions = this.options; |
| 2131 | - const prevResult = this.#currentResult; | |
| 2132 | - const prevResultState = this.#currentResultState; | |
| 2133 | - const prevResultOptions = this.#currentResultOptions; | |
| 2626 | + const prevResult = this.currentResult; | |
| 2627 | + const prevResultState = this.currentResultState; | |
| 2628 | + const prevResultOptions = this.currentResultOptions; | |
| 2134 | 2629 | const queryChange = query !== prevQuery; |
| 2135 | - const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState; | |
| 2136 | - const { state } = query; | |
| 2137 | - let newState = { ...state }; | |
| 2630 | + const queryInitialState = queryChange ? query.state : this.currentQueryInitialState; | |
| 2631 | + const prevQueryResult = queryChange ? this.currentResult : this.previousQueryResult; | |
| 2632 | + const { | |
| 2633 | + state | |
| 2634 | + } = query; | |
| 2635 | + let { | |
| 2636 | + dataUpdatedAt, | |
| 2637 | + error, | |
| 2638 | + errorUpdatedAt, | |
| 2639 | + fetchStatus, | |
| 2640 | + status | |
| 2641 | + } = state; | |
| 2642 | + let isPreviousData = false; | |
| 2138 | 2643 | let isPlaceholderData = false; |
| 2139 | - let data; | |
| 2644 | + let data; // Optimistically set result in fetching state if needed | |
| 2645 | + | |
| 2140 | 2646 | if (options._optimisticResults) { |
| 2141 | 2647 | const mounted = this.hasListeners(); |
| 2142 | 2648 | const fetchOnMount = !mounted && shouldFetchOnMount(query, options); |
| 2143 | 2649 | const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions); |
| 2650 | + | |
| 2144 | 2651 | if (fetchOnMount || fetchOptionally) { |
| 2145 | - newState = { | |
| 2146 | - ...newState, | |
| 2147 | - ...(0,_query_js__WEBPACK_IMPORTED_MODULE_2__.fetchState)(state.data, query.options) | |
| 2148 | - }; | |
| 2652 | + fetchStatus = (0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.canFetch)(query.options.networkMode) ? 'fetching' : 'paused'; | |
| 2653 | + | |
| 2654 | + if (!dataUpdatedAt) { | |
| 2655 | + status = 'loading'; | |
| 2656 | + } | |
| 2149 | 2657 | } |
| 2150 | - if (options._optimisticResults === "isRestoring") { | |
| 2151 | - newState.fetchStatus = "idle"; | |
| 2658 | + | |
| 2659 | + if (options._optimisticResults === 'isRestoring') { | |
| 2660 | + fetchStatus = 'idle'; | |
| 2152 | 2661 | } |
| 2153 | - } | |
| 2154 | - let { error, errorUpdatedAt, status } = newState; | |
| 2155 | - data = newState.data; | |
| 2156 | - let skipSelect = false; | |
| 2157 | - if (options.placeholderData !== void 0 && data === void 0 && status === "pending") { | |
| 2158 | - let placeholderData; | |
| 2159 | - if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) { | |
| 2662 | + } // Keep previous data if needed | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + if (options.keepPreviousData && !state.dataUpdatedAt && prevQueryResult != null && prevQueryResult.isSuccess && status !== 'error') { | |
| 2666 | + data = prevQueryResult.data; | |
| 2667 | + dataUpdatedAt = prevQueryResult.dataUpdatedAt; | |
| 2668 | + status = prevQueryResult.status; | |
| 2669 | + isPreviousData = true; | |
| 2670 | + } // Select data if needed | |
| 2671 | + else if (options.select && typeof state.data !== 'undefined') { | |
| 2672 | + // Memoize select result | |
| 2673 | + if (prevResult && state.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === this.selectFn) { | |
| 2674 | + data = this.selectResult; | |
| 2675 | + } else { | |
| 2676 | + try { | |
| 2677 | + this.selectFn = options.select; | |
| 2678 | + data = options.select(state.data); | |
| 2679 | + data = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.replaceData)(prevResult == null ? void 0 : prevResult.data, data, options); | |
| 2680 | + this.selectResult = data; | |
| 2681 | + this.selectError = null; | |
| 2682 | + } catch (selectError) { | |
| 2683 | + if (true) { | |
| 2684 | + this.client.getLogger().error(selectError); | |
| 2685 | + } | |
| 2686 | + | |
| 2687 | + this.selectError = selectError; | |
| 2688 | + } | |
| 2689 | + } | |
| 2690 | + } // Use query data | |
| 2691 | + else { | |
| 2692 | + data = state.data; | |
| 2693 | + } // Show placeholder data if needed | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + if (typeof options.placeholderData !== 'undefined' && typeof data === 'undefined' && status === 'loading') { | |
| 2697 | + let placeholderData; // Memoize placeholder data | |
| 2698 | + | |
| 2699 | + if (prevResult != null && prevResult.isPlaceholderData && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) { | |
| 2160 | 2700 | placeholderData = prevResult.data; |
| 2161 | - skipSelect = true; | |
| 2162 | 2701 | } else { |
| 2163 | - placeholderData = typeof options.placeholderData === "function" ? options.placeholderData( | |
| 2164 | - this.#lastQueryWithDefinedData?.state.data, | |
| 2165 | - this.#lastQueryWithDefinedData | |
| 2166 | - ) : options.placeholderData; | |
| 2702 | + placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData() : options.placeholderData; | |
| 2703 | + | |
| 2704 | + if (options.select && typeof placeholderData !== 'undefined') { | |
| 2705 | + try { | |
| 2706 | + placeholderData = options.select(placeholderData); | |
| 2707 | + this.selectError = null; | |
| 2708 | + } catch (selectError) { | |
| 2709 | + if (true) { | |
| 2710 | + this.client.getLogger().error(selectError); | |
| 2711 | + } | |
| 2712 | + | |
| 2713 | + this.selectError = selectError; | |
| 2714 | + } | |
| 2715 | + } | |
| 2167 | 2716 | } |
| 2168 | - if (placeholderData !== void 0) { | |
| 2169 | - status = "success"; | |
| 2170 | - data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.replaceData)( | |
| 2171 | - prevResult?.data, | |
| 2172 | - placeholderData, | |
| 2173 | - options | |
| 2174 | - ); | |
| 2717 | + | |
| 2718 | + if (typeof placeholderData !== 'undefined') { | |
| 2719 | + status = 'success'; | |
| 2720 | + data = (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.replaceData)(prevResult == null ? void 0 : prevResult.data, placeholderData, options); | |
| 2175 | 2721 | isPlaceholderData = true; |
| 2176 | 2722 | } |
| 2177 | 2723 | } |
| 2178 | - if (options.select && data !== void 0 && !skipSelect) { | |
| 2179 | - if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) { | |
| 2180 | - data = this.#selectResult; | |
| 2181 | - } else { | |
| 2182 | - try { | |
| 2183 | - this.#selectFn = options.select; | |
| 2184 | - data = options.select(data); | |
| 2185 | - data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.replaceData)(prevResult?.data, data, options); | |
| 2186 | - this.#selectResult = data; | |
| 2187 | - this.#selectError = null; | |
| 2188 | - } catch (selectError) { | |
| 2189 | - this.#selectError = selectError; | |
| 2190 | - } | |
| 2191 | - } | |
| 2192 | - } | |
| 2193 | - if (this.#selectError) { | |
| 2194 | - error = this.#selectError; | |
| 2195 | - data = this.#selectResult; | |
| 2724 | + | |
| 2725 | + if (this.selectError) { | |
| 2726 | + error = this.selectError; | |
| 2727 | + data = this.selectResult; | |
| 2196 | 2728 | errorUpdatedAt = Date.now(); |
| 2197 | - status = "error"; | |
| 2729 | + status = 'error'; | |
| 2198 | 2730 | } |
| 2199 | - const isFetching = newState.fetchStatus === "fetching"; | |
| 2200 | - const isPending = status === "pending"; | |
| 2201 | - const isError = status === "error"; | |
| 2202 | - const isLoading = isPending && isFetching; | |
| 2203 | - const hasData = data !== void 0; | |
| 2731 | + | |
| 2732 | + const isFetching = fetchStatus === 'fetching'; | |
| 2733 | + const isLoading = status === 'loading'; | |
| 2734 | + const isError = status === 'error'; | |
| 2204 | 2735 | const result = { |
| 2205 | 2736 | status, |
| 2206 | - fetchStatus: newState.fetchStatus, | |
| 2207 | - isPending, | |
| 2208 | - isSuccess: status === "success", | |
| 2737 | + fetchStatus, | |
| 2738 | + isLoading, | |
| 2739 | + isSuccess: status === 'success', | |
| 2209 | 2740 | isError, |
| 2210 | - isInitialLoading: isLoading, | |
| 2211 | - isLoading, | |
| 2741 | + isInitialLoading: isLoading && isFetching, | |
| 2212 | 2742 | data, |
| 2213 | - dataUpdatedAt: newState.dataUpdatedAt, | |
| 2743 | + dataUpdatedAt, | |
| 2214 | 2744 | error, |
| 2215 | 2745 | errorUpdatedAt, |
| 2216 | - failureCount: newState.fetchFailureCount, | |
| 2217 | - failureReason: newState.fetchFailureReason, | |
| 2218 | - errorUpdateCount: newState.errorUpdateCount, | |
| 2219 | - isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0, | |
| 2220 | - isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount, | |
| 2746 | + failureCount: state.fetchFailureCount, | |
| 2747 | + failureReason: state.fetchFailureReason, | |
| 2748 | + errorUpdateCount: state.errorUpdateCount, | |
| 2749 | + isFetched: state.dataUpdateCount > 0 || state.errorUpdateCount > 0, | |
| 2750 | + isFetchedAfterMount: state.dataUpdateCount > queryInitialState.dataUpdateCount || state.errorUpdateCount > queryInitialState.errorUpdateCount, | |
| 2221 | 2751 | isFetching, |
| 2222 | - isRefetching: isFetching && !isPending, | |
| 2223 | - isLoadingError: isError && !hasData, | |
| 2224 | - isPaused: newState.fetchStatus === "paused", | |
| 2752 | + isRefetching: isFetching && !isLoading, | |
| 2753 | + isLoadingError: isError && state.dataUpdatedAt === 0, | |
| 2754 | + isPaused: fetchStatus === 'paused', | |
| 2225 | 2755 | isPlaceholderData, |
| 2226 | - isRefetchError: isError && hasData, | |
| 2756 | + isPreviousData, | |
| 2757 | + isRefetchError: isError && state.dataUpdatedAt !== 0, | |
| 2227 | 2758 | isStale: isStale(query, options), |
| 2228 | 2759 | refetch: this.refetch, |
| 2229 | - promise: this.#currentThenable, | |
| 2230 | - isEnabled: (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false | |
| 2760 | + remove: this.remove | |
| 2231 | 2761 | }; |
| 2232 | - const nextResult = result; | |
| 2233 | - if (this.options.experimental_prefetchInRender) { | |
| 2234 | - const finalizeThenableIfPossible = (thenable) => { | |
| 2235 | - if (nextResult.status === "error") { | |
| 2236 | - thenable.reject(nextResult.error); | |
| 2237 | - } else if (nextResult.data !== void 0) { | |
| 2238 | - thenable.resolve(nextResult.data); | |
| 2239 | - } | |
| 2240 | - }; | |
| 2241 | - const recreateThenable = () => { | |
| 2242 | - const pending = this.#currentThenable = nextResult.promise = (0,_thenable_js__WEBPACK_IMPORTED_MODULE_4__.pendingThenable)(); | |
| 2243 | - finalizeThenableIfPossible(pending); | |
| 2244 | - }; | |
| 2245 | - const prevThenable = this.#currentThenable; | |
| 2246 | - switch (prevThenable.status) { | |
| 2247 | - case "pending": | |
| 2248 | - if (query.queryHash === prevQuery.queryHash) { | |
| 2249 | - finalizeThenableIfPossible(prevThenable); | |
| 2250 | - } | |
| 2251 | - break; | |
| 2252 | - case "fulfilled": | |
| 2253 | - if (nextResult.status === "error" || nextResult.data !== prevThenable.value) { | |
| 2254 | - recreateThenable(); | |
| 2255 | - } | |
| 2256 | - break; | |
| 2257 | - case "rejected": | |
| 2258 | - if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) { | |
| 2259 | - recreateThenable(); | |
| 2260 | - } | |
| 2261 | - break; | |
| 2262 | - } | |
| 2263 | - } | |
| 2264 | - return nextResult; | |
| 2762 | + return result; | |
| 2265 | 2763 | } |
| 2266 | - updateResult() { | |
| 2267 | - const prevResult = this.#currentResult; | |
| 2268 | - const nextResult = this.createResult(this.#currentQuery, this.options); | |
| 2269 | - this.#currentResultState = this.#currentQuery.state; | |
| 2270 | - this.#currentResultOptions = this.options; | |
| 2271 | - if (this.#currentResultState.data !== void 0) { | |
| 2272 | - this.#lastQueryWithDefinedData = this.#currentQuery; | |
| 2273 | - } | |
| 2274 | - if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.shallowEqualObjects)(nextResult, prevResult)) { | |
| 2764 | + | |
| 2765 | + updateResult(notifyOptions) { | |
| 2766 | + const prevResult = this.currentResult; | |
| 2767 | + const nextResult = this.createResult(this.currentQuery, this.options); | |
| 2768 | + this.currentResultState = this.currentQuery.state; | |
| 2769 | + this.currentResultOptions = this.options; // Only notify and update result if something has changed | |
| 2770 | + | |
| 2771 | + if ((0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(nextResult, prevResult)) { | |
| 2275 | 2772 | return; |
| 2276 | 2773 | } |
| 2277 | - this.#currentResult = nextResult; | |
| 2774 | + | |
| 2775 | + this.currentResult = nextResult; // Determine which callbacks to trigger | |
| 2776 | + | |
| 2777 | + const defaultNotifyOptions = { | |
| 2778 | + cache: true | |
| 2779 | + }; | |
| 2780 | + | |
| 2278 | 2781 | const shouldNotifyListeners = () => { |
| 2279 | 2782 | if (!prevResult) { |
| 2280 | 2783 | return true; |
| 2281 | 2784 | } |
| 2282 | - const { notifyOnChangeProps } = this.options; | |
| 2283 | - const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps; | |
| 2284 | - if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) { | |
| 2785 | + | |
| 2786 | + const { | |
| 2787 | + notifyOnChangeProps | |
| 2788 | + } = this.options; | |
| 2789 | + const notifyOnChangePropsValue = typeof notifyOnChangeProps === 'function' ? notifyOnChangeProps() : notifyOnChangeProps; | |
| 2790 | + | |
| 2791 | + if (notifyOnChangePropsValue === 'all' || !notifyOnChangePropsValue && !this.trackedProps.size) { | |
| 2285 | 2792 | return true; |
| 2286 | 2793 | } |
| 2287 | - const includedProps = new Set( | |
| 2288 | - notifyOnChangePropsValue ?? this.#trackedProps | |
| 2289 | - ); | |
| 2290 | - if (this.options.throwOnError) { | |
| 2291 | - includedProps.add("error"); | |
| 2794 | + | |
| 2795 | + const includedProps = new Set(notifyOnChangePropsValue != null ? notifyOnChangePropsValue : this.trackedProps); | |
| 2796 | + | |
| 2797 | + if (this.options.useErrorBoundary) { | |
| 2798 | + includedProps.add('error'); | |
| 2292 | 2799 | } |
| 2293 | - return Object.keys(this.#currentResult).some((key) => { | |
| 2800 | + | |
| 2801 | + return Object.keys(this.currentResult).some(key => { | |
| 2294 | 2802 | const typedKey = key; |
| 2295 | - const changed = this.#currentResult[typedKey] !== prevResult[typedKey]; | |
| 2803 | + const changed = this.currentResult[typedKey] !== prevResult[typedKey]; | |
| 2296 | 2804 | return changed && includedProps.has(typedKey); |
| 2297 | 2805 | }); |
| 2298 | 2806 | }; |
| 2299 | - this.#notify({ listeners: shouldNotifyListeners() }); | |
| 2807 | + | |
| 2808 | + if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) { | |
| 2809 | + defaultNotifyOptions.listeners = true; | |
| 2810 | + } | |
| 2811 | + | |
| 2812 | + this.notify({ ...defaultNotifyOptions, | |
| 2813 | + ...notifyOptions | |
| 2814 | + }); | |
| 2300 | 2815 | } |
| 2301 | - #updateQuery() { | |
| 2302 | - const query = this.#client.getQueryCache().build(this.#client, this.options); | |
| 2303 | - if (query === this.#currentQuery) { | |
| 2816 | + | |
| 2817 | + updateQuery() { | |
| 2818 | + const query = this.client.getQueryCache().build(this.client, this.options); | |
| 2819 | + | |
| 2820 | + if (query === this.currentQuery) { | |
| 2304 | 2821 | return; |
| 2305 | 2822 | } |
| 2306 | - const prevQuery = this.#currentQuery; | |
| 2307 | - this.#currentQuery = query; | |
| 2308 | - this.#currentQueryInitialState = query.state; | |
| 2823 | + | |
| 2824 | + const prevQuery = this.currentQuery; | |
| 2825 | + this.currentQuery = query; | |
| 2826 | + this.currentQueryInitialState = query.state; | |
| 2827 | + this.previousQueryResult = this.currentResult; | |
| 2828 | + | |
| 2309 | 2829 | if (this.hasListeners()) { |
| 2310 | - prevQuery?.removeObserver(this); | |
| 2830 | + prevQuery == null ? void 0 : prevQuery.removeObserver(this); | |
| 2311 | 2831 | query.addObserver(this); |
| 2312 | 2832 | } |
| 2313 | 2833 | } |
| 2314 | - onQueryUpdate() { | |
| 2315 | - this.updateResult(); | |
| 2834 | + | |
| 2835 | + onQueryUpdate(action) { | |
| 2836 | + const notifyOptions = {}; | |
| 2837 | + | |
| 2838 | + if (action.type === 'success') { | |
| 2839 | + notifyOptions.onSuccess = !action.manual; | |
| 2840 | + } else if (action.type === 'error' && !(0,_retryer_mjs__WEBPACK_IMPORTED_MODULE_3__.isCancelledError)(action.error)) { | |
| 2841 | + notifyOptions.onError = true; | |
| 2842 | + } | |
| 2843 | + | |
| 2844 | + this.updateResult(notifyOptions); | |
| 2845 | + | |
| 2316 | 2846 | if (this.hasListeners()) { |
| 2317 | - this.#updateTimers(); | |
| 2847 | + this.updateTimers(); | |
| 2318 | 2848 | } |
| 2319 | 2849 | } |
| 2320 | - #notify(notifyOptions) { | |
| 2321 | - _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batch(() => { | |
| 2850 | + | |
| 2851 | + notify(notifyOptions) { | |
| 2852 | + _notifyManager_mjs__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batch(() => { | |
| 2853 | + // First trigger the configuration callbacks | |
| 2854 | + if (notifyOptions.onSuccess) { | |
| 2855 | + var _this$options$onSucce, _this$options, _this$options$onSettl, _this$options2; | |
| 2856 | + | |
| 2857 | + (_this$options$onSucce = (_this$options = this.options).onSuccess) == null ? void 0 : _this$options$onSucce.call(_this$options, this.currentResult.data); | |
| 2858 | + (_this$options$onSettl = (_this$options2 = this.options).onSettled) == null ? void 0 : _this$options$onSettl.call(_this$options2, this.currentResult.data, null); | |
| 2859 | + } else if (notifyOptions.onError) { | |
| 2860 | + var _this$options$onError, _this$options3, _this$options$onSettl2, _this$options4; | |
| 2861 | + | |
| 2862 | + (_this$options$onError = (_this$options3 = this.options).onError) == null ? void 0 : _this$options$onError.call(_this$options3, this.currentResult.error); | |
| 2863 | + (_this$options$onSettl2 = (_this$options4 = this.options).onSettled) == null ? void 0 : _this$options$onSettl2.call(_this$options4, undefined, this.currentResult.error); | |
| 2864 | + } // Then trigger the listeners | |
| 2865 | + | |
| 2866 | + | |
| 2322 | 2867 | if (notifyOptions.listeners) { |
| 2323 | - this.listeners.forEach((listener) => { | |
| 2324 | - listener(this.#currentResult); | |
| 2868 | + this.listeners.forEach(({ | |
| 2869 | + listener | |
| 2870 | + }) => { | |
| 2871 | + listener(this.currentResult); | |
| 2325 | 2872 | }); |
| 2873 | + } // Then the cache listeners | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + if (notifyOptions.cache) { | |
| 2877 | + this.client.getQueryCache().notify({ | |
| 2878 | + query: this.currentQuery, | |
| 2879 | + type: 'observerResultsUpdated' | |
| 2880 | + }); | |
| 2326 | 2881 | } |
| 2327 | - this.#client.getQueryCache().notify({ | |
| 2328 | - query: this.#currentQuery, | |
| 2329 | - type: "observerResultsUpdated" | |
| 2330 | - }); | |
| 2331 | 2882 | }); |
| 2332 | 2883 | } |
| 2333 | -}; | |
| 2884 | + | |
| 2885 | +} | |
| 2886 | + | |
| 2334 | 2887 | function shouldLoadOnMount(query, options) { |
| 2335 | - return (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false); | |
| 2888 | + return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === 'error' && options.retryOnMount === false); | |
| 2336 | 2889 | } |
| 2890 | + | |
| 2337 | 2891 | function shouldFetchOnMount(query, options) { |
| 2338 | - return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount); | |
| 2892 | + return shouldLoadOnMount(query, options) || query.state.dataUpdatedAt > 0 && shouldFetchOn(query, options, options.refetchOnMount); | |
| 2339 | 2893 | } |
| 2894 | + | |
| 2340 | 2895 | function shouldFetchOn(query, options, field) { |
| 2341 | - if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false && (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(options.staleTime, query) !== "static") { | |
| 2342 | - const value = typeof field === "function" ? field(query) : field; | |
| 2343 | - return value === "always" || value !== false && isStale(query, options); | |
| 2896 | + if (options.enabled !== false) { | |
| 2897 | + const value = typeof field === 'function' ? field(query) : field; | |
| 2898 | + return value === 'always' || value !== false && isStale(query, options); | |
| 2344 | 2899 | } |
| 2900 | + | |
| 2345 | 2901 | return false; |
| 2346 | 2902 | } |
| 2903 | + | |
| 2347 | 2904 | function shouldFetchOptionally(query, prevQuery, options, prevOptions) { |
| 2348 | - return (query !== prevQuery || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); | |
| 2905 | + return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== 'error') && isStale(query, options); | |
| 2349 | 2906 | } |
| 2907 | + | |
| 2350 | 2908 | function isStale(query, options) { |
| 2351 | - return (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false && query.isStaleByTime((0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(options.staleTime, query)); | |
| 2352 | -} | |
| 2353 | -function shouldAssignObserverCurrentProperties(observer, optimisticResult) { | |
| 2354 | - if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.shallowEqualObjects)(observer.getCurrentResult(), optimisticResult)) { | |
| 2909 | + return query.isStaleByTime(options.staleTime); | |
| 2910 | +} // this function would decide if we will update the observer's 'current' | |
| 2911 | +// properties after an optimistic reading via getOptimisticResult | |
| 2912 | + | |
| 2913 | + | |
| 2914 | +function shouldAssignObserverCurrentProperties(observer, optimisticResult, options) { | |
| 2915 | + // it is important to keep this condition like this for three reasons: | |
| 2916 | + // 1. It will get removed in the v5 | |
| 2917 | + // 2. it reads: don't update the properties if we want to keep the previous | |
| 2918 | + // data. | |
| 2919 | + // 3. The opposite condition (!options.keepPreviousData) would fallthrough | |
| 2920 | + // and will result in a bad decision | |
| 2921 | + if (options.keepPreviousData) { | |
| 2922 | + return false; | |
| 2923 | + } // this means we want to put some placeholder data when pending and queryKey | |
| 2924 | + // changed. | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + if (options.placeholderData !== undefined) { | |
| 2928 | + // re-assign properties only if current data is placeholder data | |
| 2929 | + // which means that data did not arrive yet, so, if there is some cached data | |
| 2930 | + // we need to "prepare" to receive it | |
| 2931 | + return optimisticResult.isPlaceholderData; | |
| 2932 | + } // if the newly created result isn't what the observer is holding as current, | |
| 2933 | + // then we'll need to update the properties as well | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + if (observer.getCurrentResult() !== optimisticResult) { | |
| 2355 | 2937 | return true; |
| 2356 | - } | |
| 2938 | + } // basically, just keep previous properties if nothing changed | |
| 2939 | + | |
| 2940 | + | |
| 2357 | 2941 | return false; |
| 2358 | 2942 | } |
| 2359 | 2943 | |
| 2360 | -//# sourceMappingURL=queryObserver.js.map | |
| 2361 | 2944 | |
| 2945 | +//# sourceMappingURL=queryObserver.mjs.map | |
| 2946 | + | |
| 2947 | + | |
| 2362 | 2948 | /***/ }), |
| 2363 | 2949 | |
| 2364 | -/***/ "./node_modules/@tanstack/query-core/build/modern/removable.js": | |
| 2365 | -/*!*********************************************************************!*\ | |
| 2366 | - !*** ./node_modules/@tanstack/query-core/build/modern/removable.js ***! | |
| 2367 | - \*********************************************************************/ | |
| 2950 | +/***/ "./node_modules/@tanstack/query-core/build/lib/removable.mjs": | |
| 2951 | +/*!*******************************************************************!*\ | |
| 2952 | + !*** ./node_modules/@tanstack/query-core/build/lib/removable.mjs ***! | |
| 2953 | + \*******************************************************************/ | |
| 2368 | 2954 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2369 | 2955 | |
| 2370 | 2956 | __webpack_require__.r(__webpack_exports__); |
| 2371 | 2957 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -2370,48 +2956,50 @@ | ||
| 2370 | 2956 | __webpack_require__.r(__webpack_exports__); |
| 2371 | 2957 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2372 | 2958 | /* harmony export */ Removable: function() { return /* binding */ Removable; } |
| 2373 | 2959 | /* harmony export */ }); |
| 2374 | -/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); | |
| 2375 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 2376 | -// src/removable.ts | |
| 2960 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 2377 | 2961 | |
| 2378 | 2962 | |
| 2379 | -var Removable = class { | |
| 2380 | - #gcTimeout; | |
| 2963 | +class Removable { | |
| 2381 | 2964 | destroy() { |
| 2382 | 2965 | this.clearGcTimeout(); |
| 2383 | 2966 | } |
| 2967 | + | |
| 2384 | 2968 | scheduleGc() { |
| 2385 | 2969 | this.clearGcTimeout(); |
| 2386 | - if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.gcTime)) { | |
| 2387 | - this.#gcTimeout = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.timeoutManager.setTimeout(() => { | |
| 2970 | + | |
| 2971 | + if ((0,_utils_mjs__WEBPACK_IMPORTED_MODULE_0__.isValidTimeout)(this.cacheTime)) { | |
| 2972 | + this.gcTimeout = setTimeout(() => { | |
| 2388 | 2973 | this.optionalRemove(); |
| 2389 | - }, this.gcTime); | |
| 2974 | + }, this.cacheTime); | |
| 2390 | 2975 | } |
| 2391 | 2976 | } |
| 2392 | - updateGcTime(newGcTime) { | |
| 2393 | - this.gcTime = Math.max( | |
| 2394 | - this.gcTime || 0, | |
| 2395 | - newGcTime ?? (_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer ? Infinity : 5 * 60 * 1e3) | |
| 2396 | - ); | |
| 2977 | + | |
| 2978 | + updateCacheTime(newCacheTime) { | |
| 2979 | + // Default to 5 minutes (Infinity for server-side) if no cache time is set | |
| 2980 | + this.cacheTime = Math.max(this.cacheTime || 0, newCacheTime != null ? newCacheTime : _utils_mjs__WEBPACK_IMPORTED_MODULE_0__.isServer ? Infinity : 5 * 60 * 1000); | |
| 2397 | 2981 | } |
| 2982 | + | |
| 2398 | 2983 | clearGcTimeout() { |
| 2399 | - if (this.#gcTimeout) { | |
| 2400 | - _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.timeoutManager.clearTimeout(this.#gcTimeout); | |
| 2401 | - this.#gcTimeout = void 0; | |
| 2984 | + if (this.gcTimeout) { | |
| 2985 | + clearTimeout(this.gcTimeout); | |
| 2986 | + this.gcTimeout = undefined; | |
| 2402 | 2987 | } |
| 2403 | 2988 | } |
| 2404 | -}; | |
| 2405 | 2989 | |
| 2406 | -//# sourceMappingURL=removable.js.map | |
| 2990 | +} | |
| 2407 | 2991 | |
| 2992 | + | |
| 2993 | +//# sourceMappingURL=removable.mjs.map | |
| 2994 | + | |
| 2995 | + | |
| 2408 | 2996 | /***/ }), |
| 2409 | 2997 | |
| 2410 | -/***/ "./node_modules/@tanstack/query-core/build/modern/retryer.js": | |
| 2411 | -/*!*******************************************************************!*\ | |
| 2412 | - !*** ./node_modules/@tanstack/query-core/build/modern/retryer.js ***! | |
| 2413 | - \*******************************************************************/ | |
| 2998 | +/***/ "./node_modules/@tanstack/query-core/build/lib/retryer.mjs": | |
| 2999 | +/*!*****************************************************************!*\ | |
| 3000 | + !*** ./node_modules/@tanstack/query-core/build/lib/retryer.mjs ***! | |
| 3001 | + \*****************************************************************/ | |
| 2414 | 3002 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2415 | 3003 | |
| 2416 | 3004 | __webpack_require__.r(__webpack_exports__); |
| 2417 | 3005 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -2419,30 +3007,29 @@ | ||
| 2419 | 3007 | /* harmony export */ canFetch: function() { return /* binding */ canFetch; }, |
| 2420 | 3008 | /* harmony export */ createRetryer: function() { return /* binding */ createRetryer; }, |
| 2421 | 3009 | /* harmony export */ isCancelledError: function() { return /* binding */ isCancelledError; } |
| 2422 | 3010 | /* harmony export */ }); |
| 2423 | -/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); | |
| 2424 | -/* harmony import */ var _onlineManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./onlineManager.js */ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js"); | |
| 2425 | -/* harmony import */ var _thenable_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./thenable.js */ "./node_modules/@tanstack/query-core/build/modern/thenable.js"); | |
| 2426 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 2427 | -// src/retryer.ts | |
| 3011 | +/* harmony import */ var _focusManager_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focusManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/focusManager.mjs"); | |
| 3012 | +/* harmony import */ var _onlineManager_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./onlineManager.mjs */ "./node_modules/@tanstack/query-core/build/lib/onlineManager.mjs"); | |
| 3013 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 2428 | 3014 | |
| 2429 | 3015 | |
| 2430 | 3016 | |
| 2431 | 3017 | |
| 2432 | 3018 | function defaultRetryDelay(failureCount) { |
| 2433 | - return Math.min(1e3 * 2 ** failureCount, 3e4); | |
| 3019 | + return Math.min(1000 * 2 ** failureCount, 30000); | |
| 2434 | 3020 | } |
| 3021 | + | |
| 2435 | 3022 | function canFetch(networkMode) { |
| 2436 | - return (networkMode ?? "online") === "online" ? _onlineManager_js__WEBPACK_IMPORTED_MODULE_1__.onlineManager.isOnline() : true; | |
| 3023 | + return (networkMode != null ? networkMode : 'online') === 'online' ? _onlineManager_mjs__WEBPACK_IMPORTED_MODULE_0__.onlineManager.isOnline() : true; | |
| 2437 | 3024 | } |
| 2438 | -var CancelledError = class extends Error { | |
| 3025 | +class CancelledError { | |
| 2439 | 3026 | constructor(options) { |
| 2440 | - super("CancelledError"); | |
| 2441 | - this.revert = options?.revert; | |
| 2442 | - this.silent = options?.silent; | |
| 3027 | + this.revert = options == null ? void 0 : options.revert; | |
| 3028 | + this.silent = options == null ? void 0 : options.silent; | |
| 2443 | 3029 | } |
| 2444 | -}; | |
| 3030 | + | |
| 3031 | +} | |
| 2445 | 3032 | function isCancelledError(value) { |
| 2446 | 3033 | return value instanceof CancelledError; |
| 2447 | 3034 | } |
| 2448 | 3035 | function createRetryer(config) { |
| @@ -2447,80 +3034,120 @@ | ||
| 2447 | 3034 | } |
| 2448 | 3035 | function createRetryer(config) { |
| 2449 | 3036 | let isRetryCancelled = false; |
| 2450 | 3037 | let failureCount = 0; |
| 3038 | + let isResolved = false; | |
| 2451 | 3039 | let continueFn; |
| 2452 | - const thenable = (0,_thenable_js__WEBPACK_IMPORTED_MODULE_2__.pendingThenable)(); | |
| 2453 | - const isResolved = () => thenable.status !== "pending"; | |
| 2454 | - const cancel = (cancelOptions) => { | |
| 2455 | - if (!isResolved()) { | |
| 2456 | - const error = new CancelledError(cancelOptions); | |
| 2457 | - reject(error); | |
| 2458 | - config.onCancel?.(error); | |
| 3040 | + let promiseResolve; | |
| 3041 | + let promiseReject; | |
| 3042 | + const promise = new Promise((outerResolve, outerReject) => { | |
| 3043 | + promiseResolve = outerResolve; | |
| 3044 | + promiseReject = outerReject; | |
| 3045 | + }); | |
| 3046 | + | |
| 3047 | + const cancel = cancelOptions => { | |
| 3048 | + if (!isResolved) { | |
| 3049 | + reject(new CancelledError(cancelOptions)); | |
| 3050 | + config.abort == null ? void 0 : config.abort(); | |
| 2459 | 3051 | } |
| 2460 | 3052 | }; |
| 3053 | + | |
| 2461 | 3054 | const cancelRetry = () => { |
| 2462 | 3055 | isRetryCancelled = true; |
| 2463 | 3056 | }; |
| 3057 | + | |
| 2464 | 3058 | const continueRetry = () => { |
| 2465 | 3059 | isRetryCancelled = false; |
| 2466 | 3060 | }; |
| 2467 | - const canContinue = () => _focusManager_js__WEBPACK_IMPORTED_MODULE_0__.focusManager.isFocused() && (config.networkMode === "always" || _onlineManager_js__WEBPACK_IMPORTED_MODULE_1__.onlineManager.isOnline()) && config.canRun(); | |
| 2468 | - const canStart = () => canFetch(config.networkMode) && config.canRun(); | |
| 2469 | - const resolve = (value) => { | |
| 2470 | - if (!isResolved()) { | |
| 2471 | - continueFn?.(); | |
| 2472 | - thenable.resolve(value); | |
| 3061 | + | |
| 3062 | + const shouldPause = () => !_focusManager_mjs__WEBPACK_IMPORTED_MODULE_1__.focusManager.isFocused() || config.networkMode !== 'always' && !_onlineManager_mjs__WEBPACK_IMPORTED_MODULE_0__.onlineManager.isOnline(); | |
| 3063 | + | |
| 3064 | + const resolve = value => { | |
| 3065 | + if (!isResolved) { | |
| 3066 | + isResolved = true; | |
| 3067 | + config.onSuccess == null ? void 0 : config.onSuccess(value); | |
| 3068 | + continueFn == null ? void 0 : continueFn(); | |
| 3069 | + promiseResolve(value); | |
| 2473 | 3070 | } |
| 2474 | 3071 | }; |
| 2475 | - const reject = (value) => { | |
| 2476 | - if (!isResolved()) { | |
| 2477 | - continueFn?.(); | |
| 2478 | - thenable.reject(value); | |
| 3072 | + | |
| 3073 | + const reject = value => { | |
| 3074 | + if (!isResolved) { | |
| 3075 | + isResolved = true; | |
| 3076 | + config.onError == null ? void 0 : config.onError(value); | |
| 3077 | + continueFn == null ? void 0 : continueFn(); | |
| 3078 | + promiseReject(value); | |
| 2479 | 3079 | } |
| 2480 | 3080 | }; |
| 3081 | + | |
| 2481 | 3082 | const pause = () => { |
| 2482 | - return new Promise((continueResolve) => { | |
| 2483 | - continueFn = (value) => { | |
| 2484 | - if (isResolved() || canContinue()) { | |
| 3083 | + return new Promise(continueResolve => { | |
| 3084 | + continueFn = value => { | |
| 3085 | + const canContinue = isResolved || !shouldPause(); | |
| 3086 | + | |
| 3087 | + if (canContinue) { | |
| 2485 | 3088 | continueResolve(value); |
| 2486 | 3089 | } |
| 3090 | + | |
| 3091 | + return canContinue; | |
| 2487 | 3092 | }; |
| 2488 | - config.onPause?.(); | |
| 3093 | + | |
| 3094 | + config.onPause == null ? void 0 : config.onPause(); | |
| 2489 | 3095 | }).then(() => { |
| 2490 | - continueFn = void 0; | |
| 2491 | - if (!isResolved()) { | |
| 2492 | - config.onContinue?.(); | |
| 3096 | + continueFn = undefined; | |
| 3097 | + | |
| 3098 | + if (!isResolved) { | |
| 3099 | + config.onContinue == null ? void 0 : config.onContinue(); | |
| 2493 | 3100 | } |
| 2494 | 3101 | }); |
| 2495 | - }; | |
| 3102 | + }; // Create loop function | |
| 3103 | + | |
| 3104 | + | |
| 2496 | 3105 | const run = () => { |
| 2497 | - if (isResolved()) { | |
| 3106 | + // Do nothing if already resolved | |
| 3107 | + if (isResolved) { | |
| 2498 | 3108 | return; |
| 2499 | 3109 | } |
| 2500 | - let promiseOrValue; | |
| 2501 | - const initialPromise = failureCount === 0 ? config.initialPromise : void 0; | |
| 3110 | + | |
| 3111 | + let promiseOrValue; // Execute query | |
| 3112 | + | |
| 2502 | 3113 | try { |
| 2503 | - promiseOrValue = initialPromise ?? config.fn(); | |
| 3114 | + promiseOrValue = config.fn(); | |
| 2504 | 3115 | } catch (error) { |
| 2505 | 3116 | promiseOrValue = Promise.reject(error); |
| 2506 | 3117 | } |
| 2507 | - Promise.resolve(promiseOrValue).then(resolve).catch((error) => { | |
| 2508 | - if (isResolved()) { | |
| 3118 | + | |
| 3119 | + Promise.resolve(promiseOrValue).then(resolve).catch(error => { | |
| 3120 | + var _config$retry, _config$retryDelay; | |
| 3121 | + | |
| 3122 | + // Stop if the fetch is already resolved | |
| 3123 | + if (isResolved) { | |
| 2509 | 3124 | return; |
| 2510 | - } | |
| 2511 | - const retry = config.retry ?? (_utils_js__WEBPACK_IMPORTED_MODULE_3__.isServer ? 0 : 3); | |
| 2512 | - const retryDelay = config.retryDelay ?? defaultRetryDelay; | |
| 2513 | - const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay; | |
| 2514 | - const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error); | |
| 3125 | + } // Do we need to retry the request? | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + const retry = (_config$retry = config.retry) != null ? _config$retry : 3; | |
| 3129 | + const retryDelay = (_config$retryDelay = config.retryDelay) != null ? _config$retryDelay : defaultRetryDelay; | |
| 3130 | + const delay = typeof retryDelay === 'function' ? retryDelay(failureCount, error) : retryDelay; | |
| 3131 | + const shouldRetry = retry === true || typeof retry === 'number' && failureCount < retry || typeof retry === 'function' && retry(failureCount, error); | |
| 3132 | + | |
| 2515 | 3133 | if (isRetryCancelled || !shouldRetry) { |
| 3134 | + // We are done if the query does not need to be retried | |
| 2516 | 3135 | reject(error); |
| 2517 | 3136 | return; |
| 2518 | 3137 | } |
| 2519 | - failureCount++; | |
| 2520 | - config.onFail?.(failureCount, error); | |
| 2521 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.sleep)(delay).then(() => { | |
| 2522 | - return canContinue() ? void 0 : pause(); | |
| 3138 | + | |
| 3139 | + failureCount++; // Notify on fail | |
| 3140 | + | |
| 3141 | + config.onFail == null ? void 0 : config.onFail(failureCount, error); // Delay | |
| 3142 | + | |
| 3143 | + (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_2__.sleep)(delay) // Pause if the document is not visible or when the device is offline | |
| 3144 | + .then(() => { | |
| 3145 | + if (shouldPause()) { | |
| 3146 | + return pause(); | |
| 3147 | + } | |
| 3148 | + | |
| 3149 | + return; | |
| 2523 | 3150 | }).then(() => { |
| 2524 | 3151 | if (isRetryCancelled) { |
| 2525 | 3152 | reject(error); |
| 2526 | 3153 | } else { |
| @@ -2527,39 +3154,39 @@ | ||
| 2527 | 3154 | run(); |
| 2528 | 3155 | } |
| 2529 | 3156 | }); |
| 2530 | 3157 | }); |
| 2531 | - }; | |
| 3158 | + }; // Start loop | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + if (canFetch(config.networkMode)) { | |
| 3162 | + run(); | |
| 3163 | + } else { | |
| 3164 | + pause().then(run); | |
| 3165 | + } | |
| 3166 | + | |
| 2532 | 3167 | return { |
| 2533 | - promise: thenable, | |
| 2534 | - status: () => thenable.status, | |
| 3168 | + promise, | |
| 2535 | 3169 | cancel, |
| 2536 | 3170 | continue: () => { |
| 2537 | - continueFn?.(); | |
| 2538 | - return thenable; | |
| 3171 | + const didContinue = continueFn == null ? void 0 : continueFn(); | |
| 3172 | + return didContinue ? promise : Promise.resolve(); | |
| 2539 | 3173 | }, |
| 2540 | 3174 | cancelRetry, |
| 2541 | - continueRetry, | |
| 2542 | - canStart, | |
| 2543 | - start: () => { | |
| 2544 | - if (canStart()) { | |
| 2545 | - run(); | |
| 2546 | - } else { | |
| 2547 | - pause().then(run); | |
| 2548 | - } | |
| 2549 | - return thenable; | |
| 2550 | - } | |
| 3175 | + continueRetry | |
| 2551 | 3176 | }; |
| 2552 | 3177 | } |
| 2553 | 3178 | |
| 2554 | -//# sourceMappingURL=retryer.js.map | |
| 2555 | 3179 | |
| 3180 | +//# sourceMappingURL=retryer.mjs.map | |
| 3181 | + | |
| 3182 | + | |
| 2556 | 3183 | /***/ }), |
| 2557 | 3184 | |
| 2558 | -/***/ "./node_modules/@tanstack/query-core/build/modern/subscribable.js": | |
| 2559 | -/*!************************************************************************!*\ | |
| 2560 | - !*** ./node_modules/@tanstack/query-core/build/modern/subscribable.js ***! | |
| 2561 | - \************************************************************************/ | |
| 3185 | +/***/ "./node_modules/@tanstack/query-core/build/lib/subscribable.mjs": | |
| 3186 | +/*!**********************************************************************!*\ | |
| 3187 | + !*** ./node_modules/@tanstack/query-core/build/lib/subscribable.mjs ***! | |
| 3188 | + \**********************************************************************/ | |
| 2562 | 3189 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2563 | 3190 | |
| 2564 | 3191 | __webpack_require__.r(__webpack_exports__); |
| 2565 | 3192 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -2564,235 +3191,155 @@ | ||
| 2564 | 3191 | __webpack_require__.r(__webpack_exports__); |
| 2565 | 3192 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2566 | 3193 | /* harmony export */ Subscribable: function() { return /* binding */ Subscribable; } |
| 2567 | 3194 | /* harmony export */ }); |
| 2568 | -// src/subscribable.ts | |
| 2569 | -var Subscribable = class { | |
| 3195 | +class Subscribable { | |
| 2570 | 3196 | constructor() { |
| 2571 | - this.listeners = /* @__PURE__ */ new Set(); | |
| 3197 | + this.listeners = new Set(); | |
| 2572 | 3198 | this.subscribe = this.subscribe.bind(this); |
| 2573 | 3199 | } |
| 3200 | + | |
| 2574 | 3201 | subscribe(listener) { |
| 2575 | - this.listeners.add(listener); | |
| 3202 | + const identity = { | |
| 3203 | + listener | |
| 3204 | + }; | |
| 3205 | + this.listeners.add(identity); | |
| 2576 | 3206 | this.onSubscribe(); |
| 2577 | 3207 | return () => { |
| 2578 | - this.listeners.delete(listener); | |
| 3208 | + this.listeners.delete(identity); | |
| 2579 | 3209 | this.onUnsubscribe(); |
| 2580 | 3210 | }; |
| 2581 | 3211 | } |
| 3212 | + | |
| 2582 | 3213 | hasListeners() { |
| 2583 | 3214 | return this.listeners.size > 0; |
| 2584 | 3215 | } |
| 2585 | - onSubscribe() { | |
| 3216 | + | |
| 3217 | + onSubscribe() {// Do nothing | |
| 2586 | 3218 | } |
| 2587 | - onUnsubscribe() { | |
| 3219 | + | |
| 3220 | + onUnsubscribe() {// Do nothing | |
| 2588 | 3221 | } |
| 2589 | -}; | |
| 2590 | 3222 | |
| 2591 | -//# sourceMappingURL=subscribable.js.map | |
| 2592 | - | |
| 2593 | -/***/ }), | |
| 2594 | - | |
| 2595 | -/***/ "./node_modules/@tanstack/query-core/build/modern/thenable.js": | |
| 2596 | -/*!********************************************************************!*\ | |
| 2597 | - !*** ./node_modules/@tanstack/query-core/build/modern/thenable.js ***! | |
| 2598 | - \********************************************************************/ | |
| 2599 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 2600 | - | |
| 2601 | -__webpack_require__.r(__webpack_exports__); | |
| 2602 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 2603 | -/* harmony export */ pendingThenable: function() { return /* binding */ pendingThenable; }, | |
| 2604 | -/* harmony export */ tryResolveSync: function() { return /* binding */ tryResolveSync; } | |
| 2605 | -/* harmony export */ }); | |
| 2606 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 2607 | -// src/thenable.ts | |
| 2608 | - | |
| 2609 | -function pendingThenable() { | |
| 2610 | - let resolve; | |
| 2611 | - let reject; | |
| 2612 | - const thenable = new Promise((_resolve, _reject) => { | |
| 2613 | - resolve = _resolve; | |
| 2614 | - reject = _reject; | |
| 2615 | - }); | |
| 2616 | - thenable.status = "pending"; | |
| 2617 | - thenable.catch(() => { | |
| 2618 | - }); | |
| 2619 | - function finalize(data) { | |
| 2620 | - Object.assign(thenable, data); | |
| 2621 | - delete thenable.resolve; | |
| 2622 | - delete thenable.reject; | |
| 2623 | - } | |
| 2624 | - thenable.resolve = (value) => { | |
| 2625 | - finalize({ | |
| 2626 | - status: "fulfilled", | |
| 2627 | - value | |
| 2628 | - }); | |
| 2629 | - resolve(value); | |
| 2630 | - }; | |
| 2631 | - thenable.reject = (reason) => { | |
| 2632 | - finalize({ | |
| 2633 | - status: "rejected", | |
| 2634 | - reason | |
| 2635 | - }); | |
| 2636 | - reject(reason); | |
| 2637 | - }; | |
| 2638 | - return thenable; | |
| 2639 | 3223 | } |
| 2640 | -function tryResolveSync(promise) { | |
| 2641 | - let data; | |
| 2642 | - promise.then((result) => { | |
| 2643 | - data = result; | |
| 2644 | - return result; | |
| 2645 | - }, _utils_js__WEBPACK_IMPORTED_MODULE_0__.noop)?.catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); | |
| 2646 | - if (data !== void 0) { | |
| 2647 | - return { data }; | |
| 2648 | - } | |
| 2649 | - return void 0; | |
| 2650 | -} | |
| 2651 | 3224 | |
| 2652 | -//# sourceMappingURL=thenable.js.map | |
| 2653 | 3225 | |
| 2654 | -/***/ }), | |
| 3226 | +//# sourceMappingURL=subscribable.mjs.map | |
| 2655 | 3227 | |
| 2656 | -/***/ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js": | |
| 2657 | -/*!**************************************************************************!*\ | |
| 2658 | - !*** ./node_modules/@tanstack/query-core/build/modern/timeoutManager.js ***! | |
| 2659 | - \**************************************************************************/ | |
| 2660 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 2661 | 3228 | |
| 2662 | -__webpack_require__.r(__webpack_exports__); | |
| 2663 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 2664 | -/* harmony export */ TimeoutManager: function() { return /* binding */ TimeoutManager; }, | |
| 2665 | -/* harmony export */ defaultTimeoutProvider: function() { return /* binding */ defaultTimeoutProvider; }, | |
| 2666 | -/* harmony export */ systemSetTimeoutZero: function() { return /* binding */ systemSetTimeoutZero; }, | |
| 2667 | -/* harmony export */ timeoutManager: function() { return /* binding */ timeoutManager; } | |
| 2668 | -/* harmony export */ }); | |
| 2669 | -// src/timeoutManager.ts | |
| 2670 | -var defaultTimeoutProvider = { | |
| 2671 | - // We need the wrapper function syntax below instead of direct references to | |
| 2672 | - // global setTimeout etc. | |
| 2673 | - // | |
| 2674 | - // BAD: `setTimeout: setTimeout` | |
| 2675 | - // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)` | |
| 2676 | - // | |
| 2677 | - // If we use direct references here, then anything that wants to spy on or | |
| 2678 | - // replace the global setTimeout (like tests) won't work since we'll already | |
| 2679 | - // have a hard reference to the original implementation at the time when this | |
| 2680 | - // file was imported. | |
| 2681 | - setTimeout: (callback, delay) => setTimeout(callback, delay), | |
| 2682 | - clearTimeout: (timeoutId) => clearTimeout(timeoutId), | |
| 2683 | - setInterval: (callback, delay) => setInterval(callback, delay), | |
| 2684 | - clearInterval: (intervalId) => clearInterval(intervalId) | |
| 2685 | -}; | |
| 2686 | -var TimeoutManager = class { | |
| 2687 | - // We cannot have TimeoutManager<T> as we must instantiate it with a concrete | |
| 2688 | - // type at app boot; and if we leave that type, then any new timer provider | |
| 2689 | - // would need to support ReturnType<typeof setTimeout>, which is infeasible. | |
| 2690 | - // | |
| 2691 | - // We settle for type safety for the TimeoutProvider type, and accept that | |
| 2692 | - // this class is unsafe internally to allow for extension. | |
| 2693 | - #provider = defaultTimeoutProvider; | |
| 2694 | - #providerCalled = false; | |
| 2695 | - setTimeoutProvider(provider) { | |
| 2696 | - if (true) { | |
| 2697 | - if (this.#providerCalled && provider !== this.#provider) { | |
| 2698 | - console.error( | |
| 2699 | - `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`, | |
| 2700 | - { previous: this.#provider, provider } | |
| 2701 | - ); | |
| 2702 | - } | |
| 2703 | - } | |
| 2704 | - this.#provider = provider; | |
| 2705 | - if (true) { | |
| 2706 | - this.#providerCalled = false; | |
| 2707 | - } | |
| 2708 | - } | |
| 2709 | - setTimeout(callback, delay) { | |
| 2710 | - if (true) { | |
| 2711 | - this.#providerCalled = true; | |
| 2712 | - } | |
| 2713 | - return this.#provider.setTimeout(callback, delay); | |
| 2714 | - } | |
| 2715 | - clearTimeout(timeoutId) { | |
| 2716 | - this.#provider.clearTimeout(timeoutId); | |
| 2717 | - } | |
| 2718 | - setInterval(callback, delay) { | |
| 2719 | - if (true) { | |
| 2720 | - this.#providerCalled = true; | |
| 2721 | - } | |
| 2722 | - return this.#provider.setInterval(callback, delay); | |
| 2723 | - } | |
| 2724 | - clearInterval(intervalId) { | |
| 2725 | - this.#provider.clearInterval(intervalId); | |
| 2726 | - } | |
| 2727 | -}; | |
| 2728 | -var timeoutManager = new TimeoutManager(); | |
| 2729 | -function systemSetTimeoutZero(callback) { | |
| 2730 | - setTimeout(callback, 0); | |
| 2731 | -} | |
| 2732 | - | |
| 2733 | -//# sourceMappingURL=timeoutManager.js.map | |
| 2734 | - | |
| 2735 | 3229 | /***/ }), |
| 2736 | 3230 | |
| 2737 | -/***/ "./node_modules/@tanstack/query-core/build/modern/utils.js": | |
| 2738 | -/*!*****************************************************************!*\ | |
| 2739 | - !*** ./node_modules/@tanstack/query-core/build/modern/utils.js ***! | |
| 2740 | - \*****************************************************************/ | |
| 3231 | +/***/ "./node_modules/@tanstack/query-core/build/lib/utils.mjs": | |
| 3232 | +/*!***************************************************************!*\ | |
| 3233 | + !*** ./node_modules/@tanstack/query-core/build/lib/utils.mjs ***! | |
| 3234 | + \***************************************************************/ | |
| 2741 | 3235 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2742 | 3236 | |
| 2743 | 3237 | __webpack_require__.r(__webpack_exports__); |
| 2744 | 3238 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2745 | -/* harmony export */ addConsumeAwareSignal: function() { return /* binding */ addConsumeAwareSignal; }, | |
| 2746 | -/* harmony export */ addToEnd: function() { return /* binding */ addToEnd; }, | |
| 2747 | -/* harmony export */ addToStart: function() { return /* binding */ addToStart; }, | |
| 2748 | -/* harmony export */ ensureQueryFn: function() { return /* binding */ ensureQueryFn; }, | |
| 3239 | +/* harmony export */ difference: function() { return /* binding */ difference; }, | |
| 2749 | 3240 | /* harmony export */ functionalUpdate: function() { return /* binding */ functionalUpdate; }, |
| 2750 | -/* harmony export */ hashKey: function() { return /* binding */ hashKey; }, | |
| 3241 | +/* harmony export */ getAbortController: function() { return /* binding */ getAbortController; }, | |
| 3242 | +/* harmony export */ hashQueryKey: function() { return /* binding */ hashQueryKey; }, | |
| 2751 | 3243 | /* harmony export */ hashQueryKeyByOptions: function() { return /* binding */ hashQueryKeyByOptions; }, |
| 3244 | +/* harmony export */ isError: function() { return /* binding */ isError; }, | |
| 2752 | 3245 | /* harmony export */ isPlainArray: function() { return /* binding */ isPlainArray; }, |
| 2753 | 3246 | /* harmony export */ isPlainObject: function() { return /* binding */ isPlainObject; }, |
| 3247 | +/* harmony export */ isQueryKey: function() { return /* binding */ isQueryKey; }, | |
| 2754 | 3248 | /* harmony export */ isServer: function() { return /* binding */ isServer; }, |
| 2755 | 3249 | /* harmony export */ isValidTimeout: function() { return /* binding */ isValidTimeout; }, |
| 2756 | -/* harmony export */ keepPreviousData: function() { return /* binding */ keepPreviousData; }, | |
| 2757 | 3250 | /* harmony export */ matchMutation: function() { return /* binding */ matchMutation; }, |
| 2758 | 3251 | /* harmony export */ matchQuery: function() { return /* binding */ matchQuery; }, |
| 2759 | 3252 | /* harmony export */ noop: function() { return /* binding */ noop; }, |
| 3253 | +/* harmony export */ parseFilterArgs: function() { return /* binding */ parseFilterArgs; }, | |
| 3254 | +/* harmony export */ parseMutationArgs: function() { return /* binding */ parseMutationArgs; }, | |
| 3255 | +/* harmony export */ parseMutationFilterArgs: function() { return /* binding */ parseMutationFilterArgs; }, | |
| 3256 | +/* harmony export */ parseQueryArgs: function() { return /* binding */ parseQueryArgs; }, | |
| 3257 | +/* harmony export */ partialDeepEqual: function() { return /* binding */ partialDeepEqual; }, | |
| 2760 | 3258 | /* harmony export */ partialMatchKey: function() { return /* binding */ partialMatchKey; }, |
| 3259 | +/* harmony export */ replaceAt: function() { return /* binding */ replaceAt; }, | |
| 2761 | 3260 | /* harmony export */ replaceData: function() { return /* binding */ replaceData; }, |
| 2762 | 3261 | /* harmony export */ replaceEqualDeep: function() { return /* binding */ replaceEqualDeep; }, |
| 2763 | -/* harmony export */ resolveEnabled: function() { return /* binding */ resolveEnabled; }, | |
| 2764 | -/* harmony export */ resolveStaleTime: function() { return /* binding */ resolveStaleTime; }, | |
| 3262 | +/* harmony export */ scheduleMicrotask: function() { return /* binding */ scheduleMicrotask; }, | |
| 2765 | 3263 | /* harmony export */ shallowEqualObjects: function() { return /* binding */ shallowEqualObjects; }, |
| 2766 | -/* harmony export */ shouldThrowError: function() { return /* binding */ shouldThrowError; }, | |
| 2767 | -/* harmony export */ skipToken: function() { return /* binding */ skipToken; }, | |
| 2768 | 3264 | /* harmony export */ sleep: function() { return /* binding */ sleep; }, |
| 2769 | 3265 | /* harmony export */ timeUntilStale: function() { return /* binding */ timeUntilStale; } |
| 2770 | 3266 | /* harmony export */ }); |
| 2771 | -/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); | |
| 2772 | -// src/utils.ts | |
| 2773 | - | |
| 2774 | -var isServer = typeof window === "undefined" || "Deno" in globalThis; | |
| 3267 | +// TYPES | |
| 3268 | +// UTILS | |
| 3269 | +const isServer = typeof window === 'undefined' || 'Deno' in window; | |
| 2775 | 3270 | function noop() { |
| 3271 | + return undefined; | |
| 2776 | 3272 | } |
| 2777 | 3273 | function functionalUpdate(updater, input) { |
| 2778 | - return typeof updater === "function" ? updater(input) : updater; | |
| 3274 | + return typeof updater === 'function' ? updater(input) : updater; | |
| 2779 | 3275 | } |
| 2780 | 3276 | function isValidTimeout(value) { |
| 2781 | - return typeof value === "number" && value >= 0 && value !== Infinity; | |
| 3277 | + return typeof value === 'number' && value >= 0 && value !== Infinity; | |
| 2782 | 3278 | } |
| 3279 | +function difference(array1, array2) { | |
| 3280 | + return array1.filter(x => !array2.includes(x)); | |
| 3281 | +} | |
| 3282 | +function replaceAt(array, index, value) { | |
| 3283 | + const copy = array.slice(0); | |
| 3284 | + copy[index] = value; | |
| 3285 | + return copy; | |
| 3286 | +} | |
| 2783 | 3287 | function timeUntilStale(updatedAt, staleTime) { |
| 2784 | 3288 | return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); |
| 2785 | 3289 | } |
| 2786 | -function resolveStaleTime(staleTime, query) { | |
| 2787 | - return typeof staleTime === "function" ? staleTime(query) : staleTime; | |
| 3290 | +function parseQueryArgs(arg1, arg2, arg3) { | |
| 3291 | + if (!isQueryKey(arg1)) { | |
| 3292 | + return arg1; | |
| 3293 | + } | |
| 3294 | + | |
| 3295 | + if (typeof arg2 === 'function') { | |
| 3296 | + return { ...arg3, | |
| 3297 | + queryKey: arg1, | |
| 3298 | + queryFn: arg2 | |
| 3299 | + }; | |
| 3300 | + } | |
| 3301 | + | |
| 3302 | + return { ...arg2, | |
| 3303 | + queryKey: arg1 | |
| 3304 | + }; | |
| 2788 | 3305 | } |
| 2789 | -function resolveEnabled(enabled, query) { | |
| 2790 | - return typeof enabled === "function" ? enabled(query) : enabled; | |
| 3306 | +function parseMutationArgs(arg1, arg2, arg3) { | |
| 3307 | + if (isQueryKey(arg1)) { | |
| 3308 | + if (typeof arg2 === 'function') { | |
| 3309 | + return { ...arg3, | |
| 3310 | + mutationKey: arg1, | |
| 3311 | + mutationFn: arg2 | |
| 3312 | + }; | |
| 3313 | + } | |
| 3314 | + | |
| 3315 | + return { ...arg2, | |
| 3316 | + mutationKey: arg1 | |
| 3317 | + }; | |
| 3318 | + } | |
| 3319 | + | |
| 3320 | + if (typeof arg1 === 'function') { | |
| 3321 | + return { ...arg2, | |
| 3322 | + mutationFn: arg1 | |
| 3323 | + }; | |
| 3324 | + } | |
| 3325 | + | |
| 3326 | + return { ...arg1 | |
| 3327 | + }; | |
| 2791 | 3328 | } |
| 3329 | +function parseFilterArgs(arg1, arg2, arg3) { | |
| 3330 | + return isQueryKey(arg1) ? [{ ...arg2, | |
| 3331 | + queryKey: arg1 | |
| 3332 | + }, arg3] : [arg1 || {}, arg2]; | |
| 3333 | +} | |
| 3334 | +function parseMutationFilterArgs(arg1, arg2, arg3) { | |
| 3335 | + return isQueryKey(arg1) ? [{ ...arg2, | |
| 3336 | + mutationKey: arg1 | |
| 3337 | + }, arg3] : [arg1 || {}, arg2]; | |
| 3338 | +} | |
| 2792 | 3339 | function matchQuery(filters, query) { |
| 2793 | 3340 | const { |
| 2794 | - type = "all", | |
| 3341 | + type = 'all', | |
| 2795 | 3342 | exact, |
| 2796 | 3343 | fetchStatus, |
| 2797 | 3344 | predicate, |
| 2798 | 3345 | queryKey, |
| @@ -2797,9 +3344,10 @@ | ||
| 2797 | 3344 | predicate, |
| 2798 | 3345 | queryKey, |
| 2799 | 3346 | stale |
| 2800 | 3347 | } = filters; |
| 2801 | - if (queryKey) { | |
| 3348 | + | |
| 3349 | + if (isQueryKey(queryKey)) { | |
| 2802 | 3350 | if (exact) { |
| 2803 | 3351 | if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) { |
| 2804 | 3352 | return false; |
| 2805 | 3353 | } |
| @@ -2806,36 +3354,50 @@ | ||
| 2806 | 3354 | } else if (!partialMatchKey(query.queryKey, queryKey)) { |
| 2807 | 3355 | return false; |
| 2808 | 3356 | } |
| 2809 | 3357 | } |
| 2810 | - if (type !== "all") { | |
| 3358 | + | |
| 3359 | + if (type !== 'all') { | |
| 2811 | 3360 | const isActive = query.isActive(); |
| 2812 | - if (type === "active" && !isActive) { | |
| 3361 | + | |
| 3362 | + if (type === 'active' && !isActive) { | |
| 2813 | 3363 | return false; |
| 2814 | 3364 | } |
| 2815 | - if (type === "inactive" && isActive) { | |
| 3365 | + | |
| 3366 | + if (type === 'inactive' && isActive) { | |
| 2816 | 3367 | return false; |
| 2817 | 3368 | } |
| 2818 | 3369 | } |
| 2819 | - if (typeof stale === "boolean" && query.isStale() !== stale) { | |
| 3370 | + | |
| 3371 | + if (typeof stale === 'boolean' && query.isStale() !== stale) { | |
| 2820 | 3372 | return false; |
| 2821 | 3373 | } |
| 2822 | - if (fetchStatus && fetchStatus !== query.state.fetchStatus) { | |
| 3374 | + | |
| 3375 | + if (typeof fetchStatus !== 'undefined' && fetchStatus !== query.state.fetchStatus) { | |
| 2823 | 3376 | return false; |
| 2824 | 3377 | } |
| 3378 | + | |
| 2825 | 3379 | if (predicate && !predicate(query)) { |
| 2826 | 3380 | return false; |
| 2827 | 3381 | } |
| 3382 | + | |
| 2828 | 3383 | return true; |
| 2829 | 3384 | } |
| 2830 | 3385 | function matchMutation(filters, mutation) { |
| 2831 | - const { exact, status, predicate, mutationKey } = filters; | |
| 2832 | - if (mutationKey) { | |
| 3386 | + const { | |
| 3387 | + exact, | |
| 3388 | + fetching, | |
| 3389 | + predicate, | |
| 3390 | + mutationKey | |
| 3391 | + } = filters; | |
| 3392 | + | |
| 3393 | + if (isQueryKey(mutationKey)) { | |
| 2833 | 3394 | if (!mutation.options.mutationKey) { |
| 2834 | 3395 | return false; |
| 2835 | 3396 | } |
| 3397 | + | |
| 2836 | 3398 | if (exact) { |
| 2837 | - if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) { | |
| 3399 | + if (hashQueryKey(mutation.options.mutationKey) !== hashQueryKey(mutationKey)) { | |
| 2838 | 3400 | return false; |
| 2839 | 3401 | } |
| 2840 | 3402 | } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) { |
| 2841 | 3403 | return false; |
| @@ -2840,253 +3402,250 @@ | ||
| 2840 | 3402 | } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) { |
| 2841 | 3403 | return false; |
| 2842 | 3404 | } |
| 2843 | 3405 | } |
| 2844 | - if (status && mutation.state.status !== status) { | |
| 3406 | + | |
| 3407 | + if (typeof fetching === 'boolean' && mutation.state.status === 'loading' !== fetching) { | |
| 2845 | 3408 | return false; |
| 2846 | 3409 | } |
| 3410 | + | |
| 2847 | 3411 | if (predicate && !predicate(mutation)) { |
| 2848 | 3412 | return false; |
| 2849 | 3413 | } |
| 3414 | + | |
| 2850 | 3415 | return true; |
| 2851 | 3416 | } |
| 2852 | 3417 | function hashQueryKeyByOptions(queryKey, options) { |
| 2853 | - const hashFn = options?.queryKeyHashFn || hashKey; | |
| 3418 | + const hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashQueryKey; | |
| 2854 | 3419 | return hashFn(queryKey); |
| 2855 | 3420 | } |
| 2856 | -function hashKey(queryKey) { | |
| 2857 | - return JSON.stringify( | |
| 2858 | - queryKey, | |
| 2859 | - (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => { | |
| 2860 | - result[key] = val[key]; | |
| 2861 | - return result; | |
| 2862 | - }, {}) : val | |
| 2863 | - ); | |
| 3421 | +/** | |
| 3422 | + * Default query keys hash function. | |
| 3423 | + * Hashes the value into a stable hash. | |
| 3424 | + */ | |
| 3425 | + | |
| 3426 | +function hashQueryKey(queryKey) { | |
| 3427 | + return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => { | |
| 3428 | + result[key] = val[key]; | |
| 3429 | + return result; | |
| 3430 | + }, {}) : val); | |
| 2864 | 3431 | } |
| 3432 | +/** | |
| 3433 | + * Checks if key `b` partially matches with key `a`. | |
| 3434 | + */ | |
| 3435 | + | |
| 2865 | 3436 | function partialMatchKey(a, b) { |
| 3437 | + return partialDeepEqual(a, b); | |
| 3438 | +} | |
| 3439 | +/** | |
| 3440 | + * Checks if `b` partially matches with `a`. | |
| 3441 | + */ | |
| 3442 | + | |
| 3443 | +function partialDeepEqual(a, b) { | |
| 2866 | 3444 | if (a === b) { |
| 2867 | 3445 | return true; |
| 2868 | 3446 | } |
| 3447 | + | |
| 2869 | 3448 | if (typeof a !== typeof b) { |
| 2870 | 3449 | return false; |
| 2871 | 3450 | } |
| 2872 | - if (a && b && typeof a === "object" && typeof b === "object") { | |
| 2873 | - return Object.keys(b).every((key) => partialMatchKey(a[key], b[key])); | |
| 3451 | + | |
| 3452 | + if (a && b && typeof a === 'object' && typeof b === 'object') { | |
| 3453 | + return !Object.keys(b).some(key => !partialDeepEqual(a[key], b[key])); | |
| 2874 | 3454 | } |
| 3455 | + | |
| 2875 | 3456 | return false; |
| 2876 | 3457 | } |
| 2877 | -var hasOwn = Object.prototype.hasOwnProperty; | |
| 3458 | +/** | |
| 3459 | + * This function returns `a` if `b` is deeply equal. | |
| 3460 | + * If not, it will replace any deeply equal children of `b` with those of `a`. | |
| 3461 | + * This can be used for structural sharing between JSON values for example. | |
| 3462 | + */ | |
| 3463 | + | |
| 2878 | 3464 | function replaceEqualDeep(a, b) { |
| 2879 | 3465 | if (a === b) { |
| 2880 | 3466 | return a; |
| 2881 | 3467 | } |
| 3468 | + | |
| 2882 | 3469 | const array = isPlainArray(a) && isPlainArray(b); |
| 2883 | - if (!array && !(isPlainObject(a) && isPlainObject(b))) return b; | |
| 2884 | - const aItems = array ? a : Object.keys(a); | |
| 2885 | - const aSize = aItems.length; | |
| 2886 | - const bItems = array ? b : Object.keys(b); | |
| 2887 | - const bSize = bItems.length; | |
| 2888 | - const copy = array ? new Array(bSize) : {}; | |
| 2889 | - let equalItems = 0; | |
| 2890 | - for (let i = 0; i < bSize; i++) { | |
| 2891 | - const key = array ? i : bItems[i]; | |
| 2892 | - const aItem = a[key]; | |
| 2893 | - const bItem = b[key]; | |
| 2894 | - if (aItem === bItem) { | |
| 2895 | - copy[key] = aItem; | |
| 2896 | - if (array ? i < aSize : hasOwn.call(a, key)) equalItems++; | |
| 2897 | - continue; | |
| 3470 | + | |
| 3471 | + if (array || isPlainObject(a) && isPlainObject(b)) { | |
| 3472 | + const aSize = array ? a.length : Object.keys(a).length; | |
| 3473 | + const bItems = array ? b : Object.keys(b); | |
| 3474 | + const bSize = bItems.length; | |
| 3475 | + const copy = array ? [] : {}; | |
| 3476 | + let equalItems = 0; | |
| 3477 | + | |
| 3478 | + for (let i = 0; i < bSize; i++) { | |
| 3479 | + const key = array ? i : bItems[i]; | |
| 3480 | + copy[key] = replaceEqualDeep(a[key], b[key]); | |
| 3481 | + | |
| 3482 | + if (copy[key] === a[key]) { | |
| 3483 | + equalItems++; | |
| 3484 | + } | |
| 2898 | 3485 | } |
| 2899 | - if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") { | |
| 2900 | - copy[key] = bItem; | |
| 2901 | - continue; | |
| 2902 | - } | |
| 2903 | - const v = replaceEqualDeep(aItem, bItem); | |
| 2904 | - copy[key] = v; | |
| 2905 | - if (v === aItem) equalItems++; | |
| 3486 | + | |
| 3487 | + return aSize === bSize && equalItems === aSize ? a : copy; | |
| 2906 | 3488 | } |
| 2907 | - return aSize === bSize && equalItems === aSize ? a : copy; | |
| 3489 | + | |
| 3490 | + return b; | |
| 2908 | 3491 | } |
| 3492 | +/** | |
| 3493 | + * Shallow compare objects. Only works with objects that always have the same properties. | |
| 3494 | + */ | |
| 3495 | + | |
| 2909 | 3496 | function shallowEqualObjects(a, b) { |
| 2910 | - if (!b || Object.keys(a).length !== Object.keys(b).length) { | |
| 3497 | + if (a && !b || b && !a) { | |
| 2911 | 3498 | return false; |
| 2912 | 3499 | } |
| 3500 | + | |
| 2913 | 3501 | for (const key in a) { |
| 2914 | 3502 | if (a[key] !== b[key]) { |
| 2915 | 3503 | return false; |
| 2916 | 3504 | } |
| 2917 | 3505 | } |
| 3506 | + | |
| 2918 | 3507 | return true; |
| 2919 | 3508 | } |
| 2920 | 3509 | function isPlainArray(value) { |
| 2921 | 3510 | return Array.isArray(value) && value.length === Object.keys(value).length; |
| 2922 | -} | |
| 3511 | +} // Copied from: https://github.com/jonschlinkert/is-plain-object | |
| 3512 | + | |
| 2923 | 3513 | function isPlainObject(o) { |
| 2924 | 3514 | if (!hasObjectPrototype(o)) { |
| 2925 | 3515 | return false; |
| 2926 | - } | |
| 3516 | + } // If has modified constructor | |
| 3517 | + | |
| 3518 | + | |
| 2927 | 3519 | const ctor = o.constructor; |
| 2928 | - if (ctor === void 0) { | |
| 3520 | + | |
| 3521 | + if (typeof ctor === 'undefined') { | |
| 2929 | 3522 | return true; |
| 2930 | - } | |
| 3523 | + } // If has modified prototype | |
| 3524 | + | |
| 3525 | + | |
| 2931 | 3526 | const prot = ctor.prototype; |
| 3527 | + | |
| 2932 | 3528 | if (!hasObjectPrototype(prot)) { |
| 2933 | 3529 | return false; |
| 2934 | - } | |
| 2935 | - if (!prot.hasOwnProperty("isPrototypeOf")) { | |
| 3530 | + } // If constructor does not have an Object-specific method | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + if (!prot.hasOwnProperty('isPrototypeOf')) { | |
| 2936 | 3534 | return false; |
| 2937 | - } | |
| 2938 | - if (Object.getPrototypeOf(o) !== Object.prototype) { | |
| 2939 | - return false; | |
| 2940 | - } | |
| 3535 | + } // Most likely a plain Object | |
| 3536 | + | |
| 3537 | + | |
| 2941 | 3538 | return true; |
| 2942 | 3539 | } |
| 3540 | + | |
| 2943 | 3541 | function hasObjectPrototype(o) { |
| 2944 | - return Object.prototype.toString.call(o) === "[object Object]"; | |
| 3542 | + return Object.prototype.toString.call(o) === '[object Object]'; | |
| 2945 | 3543 | } |
| 3544 | + | |
| 3545 | +function isQueryKey(value) { | |
| 3546 | + return Array.isArray(value); | |
| 3547 | +} | |
| 3548 | +function isError(value) { | |
| 3549 | + return value instanceof Error; | |
| 3550 | +} | |
| 2946 | 3551 | function sleep(timeout) { |
| 2947 | - return new Promise((resolve) => { | |
| 2948 | - _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.timeoutManager.setTimeout(resolve, timeout); | |
| 3552 | + return new Promise(resolve => { | |
| 3553 | + setTimeout(resolve, timeout); | |
| 2949 | 3554 | }); |
| 2950 | 3555 | } |
| 3556 | +/** | |
| 3557 | + * Schedules a microtask. | |
| 3558 | + * This can be useful to schedule state updates after rendering. | |
| 3559 | + */ | |
| 3560 | + | |
| 3561 | +function scheduleMicrotask(callback) { | |
| 3562 | + sleep(0).then(callback); | |
| 3563 | +} | |
| 3564 | +function getAbortController() { | |
| 3565 | + if (typeof AbortController === 'function') { | |
| 3566 | + return new AbortController(); | |
| 3567 | + } | |
| 3568 | + | |
| 3569 | + return; | |
| 3570 | +} | |
| 2951 | 3571 | function replaceData(prevData, data, options) { |
| 2952 | - if (typeof options.structuralSharing === "function") { | |
| 3572 | + // Use prev data if an isDataEqual function is defined and returns `true` | |
| 3573 | + if (options.isDataEqual != null && options.isDataEqual(prevData, data)) { | |
| 3574 | + return prevData; | |
| 3575 | + } else if (typeof options.structuralSharing === 'function') { | |
| 2953 | 3576 | return options.structuralSharing(prevData, data); |
| 2954 | 3577 | } else if (options.structuralSharing !== false) { |
| 2955 | - if (true) { | |
| 2956 | - try { | |
| 2957 | - return replaceEqualDeep(prevData, data); | |
| 2958 | - } catch (error) { | |
| 2959 | - console.error( | |
| 2960 | - `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}` | |
| 2961 | - ); | |
| 2962 | - throw error; | |
| 2963 | - } | |
| 2964 | - } | |
| 2965 | - // removed by dead control flow | |
| 3578 | + // Structurally share data between prev and new data if needed | |
| 3579 | + return replaceEqualDeep(prevData, data); | |
| 3580 | + } | |
| 2966 | 3581 | |
| 2967 | - } | |
| 2968 | 3582 | return data; |
| 2969 | 3583 | } |
| 2970 | -function keepPreviousData(previousData) { | |
| 2971 | - return previousData; | |
| 2972 | -} | |
| 2973 | -function addToEnd(items, item, max = 0) { | |
| 2974 | - const newItems = [...items, item]; | |
| 2975 | - return max && newItems.length > max ? newItems.slice(1) : newItems; | |
| 2976 | -} | |
| 2977 | -function addToStart(items, item, max = 0) { | |
| 2978 | - const newItems = [item, ...items]; | |
| 2979 | - return max && newItems.length > max ? newItems.slice(0, -1) : newItems; | |
| 2980 | -} | |
| 2981 | -var skipToken = Symbol(); | |
| 2982 | -function ensureQueryFn(options, fetchOptions) { | |
| 2983 | - if (true) { | |
| 2984 | - if (options.queryFn === skipToken) { | |
| 2985 | - console.error( | |
| 2986 | - `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'` | |
| 2987 | - ); | |
| 2988 | - } | |
| 2989 | - } | |
| 2990 | - if (!options.queryFn && fetchOptions?.initialPromise) { | |
| 2991 | - return () => fetchOptions.initialPromise; | |
| 2992 | - } | |
| 2993 | - if (!options.queryFn || options.queryFn === skipToken) { | |
| 2994 | - return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`)); | |
| 2995 | - } | |
| 2996 | - return options.queryFn; | |
| 2997 | -} | |
| 2998 | -function shouldThrowError(throwOnError, params) { | |
| 2999 | - if (typeof throwOnError === "function") { | |
| 3000 | - return throwOnError(...params); | |
| 3001 | - } | |
| 3002 | - return !!throwOnError; | |
| 3003 | -} | |
| 3004 | -function addConsumeAwareSignal(object, getSignal, onCancelled) { | |
| 3005 | - let consumed = false; | |
| 3006 | - let signal; | |
| 3007 | - Object.defineProperty(object, "signal", { | |
| 3008 | - enumerable: true, | |
| 3009 | - get: () => { | |
| 3010 | - signal ??= getSignal(); | |
| 3011 | - if (consumed) { | |
| 3012 | - return signal; | |
| 3013 | - } | |
| 3014 | - consumed = true; | |
| 3015 | - if (signal.aborted) { | |
| 3016 | - onCancelled(); | |
| 3017 | - } else { | |
| 3018 | - signal.addEventListener("abort", onCancelled, { once: true }); | |
| 3019 | - } | |
| 3020 | - return signal; | |
| 3021 | - } | |
| 3022 | - }); | |
| 3023 | - return object; | |
| 3024 | -} | |
| 3025 | 3584 | |
| 3026 | -//# sourceMappingURL=utils.js.map | |
| 3027 | 3585 | |
| 3586 | +//# sourceMappingURL=utils.mjs.map | |
| 3587 | + | |
| 3588 | + | |
| 3028 | 3589 | /***/ }), |
| 3029 | 3590 | |
| 3030 | -/***/ "./node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js": | |
| 3031 | -/*!********************************************************************************!*\ | |
| 3032 | - !*** ./node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js ***! | |
| 3033 | - \********************************************************************************/ | |
| 3591 | +/***/ "./node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs": | |
| 3592 | +/*!******************************************************************************!*\ | |
| 3593 | + !*** ./node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs ***! | |
| 3594 | + \******************************************************************************/ | |
| 3034 | 3595 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3035 | 3596 | |
| 3036 | 3597 | __webpack_require__.r(__webpack_exports__); |
| 3037 | 3598 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3038 | -/* harmony export */ IsRestoringProvider: function() { return /* binding */ IsRestoringProvider; }, | |
| 3039 | -/* harmony export */ useIsRestoring: function() { return /* binding */ useIsRestoring; } | |
| 3599 | +/* harmony export */ QueryClientProvider: function() { return /* binding */ QueryClientProvider; }, | |
| 3600 | +/* harmony export */ defaultContext: function() { return /* binding */ defaultContext; }, | |
| 3601 | +/* harmony export */ useQueryClient: function() { return /* binding */ useQueryClient; } | |
| 3040 | 3602 | /* harmony export */ }); |
| 3041 | 3603 | /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3042 | -"use client"; | |
| 3604 | +'use client'; | |
| 3043 | 3605 | |
| 3044 | -// src/IsRestoringProvider.ts | |
| 3045 | 3606 | |
| 3046 | -var IsRestoringContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(false); | |
| 3047 | -var useIsRestoring = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(IsRestoringContext); | |
| 3048 | -var IsRestoringProvider = IsRestoringContext.Provider; | |
| 3607 | +const defaultContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(undefined); | |
| 3608 | +const QueryClientSharingContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(false); // If we are given a context, we will use it. | |
| 3609 | +// Otherwise, if contextSharing is on, we share the first and at least one | |
| 3610 | +// instance of the context across the window | |
| 3611 | +// to ensure that if React Query is used across | |
| 3612 | +// different bundles or microfrontends they will | |
| 3613 | +// all use the same **instance** of context, regardless | |
| 3614 | +// of module scoping. | |
| 3049 | 3615 | |
| 3050 | -//# sourceMappingURL=IsRestoringProvider.js.map | |
| 3616 | +function getQueryClientContext(context, contextSharing) { | |
| 3617 | + if (context) { | |
| 3618 | + return context; | |
| 3619 | + } | |
| 3051 | 3620 | |
| 3052 | -/***/ }), | |
| 3621 | + if (contextSharing && typeof window !== 'undefined') { | |
| 3622 | + if (!window.ReactQueryClientContext) { | |
| 3623 | + window.ReactQueryClientContext = defaultContext; | |
| 3624 | + } | |
| 3053 | 3625 | |
| 3054 | -/***/ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js": | |
| 3055 | -/*!********************************************************************************!*\ | |
| 3056 | - !*** ./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js ***! | |
| 3057 | - \********************************************************************************/ | |
| 3058 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3626 | + return window.ReactQueryClientContext; | |
| 3627 | + } | |
| 3059 | 3628 | |
| 3060 | -__webpack_require__.r(__webpack_exports__); | |
| 3061 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3062 | -/* harmony export */ QueryClientContext: function() { return /* binding */ QueryClientContext; }, | |
| 3063 | -/* harmony export */ QueryClientProvider: function() { return /* binding */ QueryClientProvider; }, | |
| 3064 | -/* harmony export */ useQueryClient: function() { return /* binding */ useQueryClient; } | |
| 3065 | -/* harmony export */ }); | |
| 3066 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 3067 | -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); | |
| 3068 | -"use client"; | |
| 3629 | + return defaultContext; | |
| 3630 | +} | |
| 3069 | 3631 | |
| 3070 | -// src/QueryClientProvider.tsx | |
| 3632 | +const useQueryClient = ({ | |
| 3633 | + context | |
| 3634 | +} = {}) => { | |
| 3635 | + const queryClient = react__WEBPACK_IMPORTED_MODULE_0__.useContext(getQueryClientContext(context, react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryClientSharingContext))); | |
| 3071 | 3636 | |
| 3637 | + if (!queryClient) { | |
| 3638 | + throw new Error('No QueryClient set, use QueryClientProvider to set one'); | |
| 3639 | + } | |
| 3072 | 3640 | |
| 3073 | -var QueryClientContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext( | |
| 3074 | - void 0 | |
| 3075 | -); | |
| 3076 | -var useQueryClient = (queryClient) => { | |
| 3077 | - const client = react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryClientContext); | |
| 3078 | - if (queryClient) { | |
| 3079 | - return queryClient; | |
| 3080 | - } | |
| 3081 | - if (!client) { | |
| 3082 | - throw new Error("No QueryClient set, use QueryClientProvider to set one"); | |
| 3083 | - } | |
| 3084 | - return client; | |
| 3641 | + return queryClient; | |
| 3085 | 3642 | }; |
| 3086 | -var QueryClientProvider = ({ | |
| 3643 | +const QueryClientProvider = ({ | |
| 3087 | 3644 | client, |
| 3088 | - children | |
| 3645 | + children, | |
| 3646 | + context, | |
| 3647 | + contextSharing = false | |
| 3089 | 3648 | }) => { |
| 3090 | 3649 | react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3091 | 3650 | client.mount(); |
| 3092 | 3651 | return () => { |
| @@ -3092,19 +3651,31 @@ | ||
| 3092 | 3651 | return () => { |
| 3093 | 3652 | client.unmount(); |
| 3094 | 3653 | }; |
| 3095 | 3654 | }, [client]); |
| 3096 | - return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(QueryClientContext.Provider, { value: client, children }); | |
| 3655 | + | |
| 3656 | + if ( true && contextSharing) { | |
| 3657 | + client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version"); | |
| 3658 | + } | |
| 3659 | + | |
| 3660 | + const Context = getQueryClientContext(context, contextSharing); | |
| 3661 | + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(QueryClientSharingContext.Provider, { | |
| 3662 | + value: !context && contextSharing | |
| 3663 | + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Context.Provider, { | |
| 3664 | + value: client | |
| 3665 | + }, children)); | |
| 3097 | 3666 | }; |
| 3098 | 3667 | |
| 3099 | -//# sourceMappingURL=QueryClientProvider.js.map | |
| 3100 | 3668 | |
| 3669 | +//# sourceMappingURL=QueryClientProvider.mjs.map | |
| 3670 | + | |
| 3671 | + | |
| 3101 | 3672 | /***/ }), |
| 3102 | 3673 | |
| 3103 | -/***/ "./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js": | |
| 3104 | -/*!************************************************************************************!*\ | |
| 3105 | - !*** ./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js ***! | |
| 3106 | - \************************************************************************************/ | |
| 3674 | +/***/ "./node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.mjs": | |
| 3675 | +/*!**********************************************************************************!*\ | |
| 3676 | + !*** ./node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.mjs ***! | |
| 3677 | + \**********************************************************************************/ | |
| 3107 | 3678 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3108 | 3679 | |
| 3109 | 3680 | __webpack_require__.r(__webpack_exports__); |
| 3110 | 3681 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -3111,14 +3682,11 @@ | ||
| 3111 | 3682 | /* harmony export */ QueryErrorResetBoundary: function() { return /* binding */ QueryErrorResetBoundary; }, |
| 3112 | 3683 | /* harmony export */ useQueryErrorResetBoundary: function() { return /* binding */ useQueryErrorResetBoundary; } |
| 3113 | 3684 | /* harmony export */ }); |
| 3114 | 3685 | /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3115 | -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); | |
| 3116 | -"use client"; | |
| 3686 | +'use client'; | |
| 3117 | 3687 | |
| 3118 | -// src/QueryErrorResetBoundary.tsx | |
| 3119 | 3688 | |
| 3120 | - | |
| 3121 | 3689 | function createValue() { |
| 3122 | 3690 | let isReset = false; |
| 3123 | 3691 | return { |
| 3124 | 3692 | clearReset: () => { |
| @@ -3131,25 +3699,32 @@ | ||
| 3131 | 3699 | return isReset; |
| 3132 | 3700 | } |
| 3133 | 3701 | }; |
| 3134 | 3702 | } |
| 3135 | -var QueryErrorResetBoundaryContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(createValue()); | |
| 3136 | -var useQueryErrorResetBoundary = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryErrorResetBoundaryContext); | |
| 3137 | -var QueryErrorResetBoundary = ({ | |
| 3703 | + | |
| 3704 | +const QueryErrorResetBoundaryContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(createValue()); // HOOK | |
| 3705 | + | |
| 3706 | +const useQueryErrorResetBoundary = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryErrorResetBoundaryContext); // COMPONENT | |
| 3707 | + | |
| 3708 | +const QueryErrorResetBoundary = ({ | |
| 3138 | 3709 | children |
| 3139 | 3710 | }) => { |
| 3140 | 3711 | const [value] = react__WEBPACK_IMPORTED_MODULE_0__.useState(() => createValue()); |
| 3141 | - return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(QueryErrorResetBoundaryContext.Provider, { value, children: typeof children === "function" ? children(value) : children }); | |
| 3712 | + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(QueryErrorResetBoundaryContext.Provider, { | |
| 3713 | + value: value | |
| 3714 | + }, typeof children === 'function' ? children(value) : children); | |
| 3142 | 3715 | }; |
| 3143 | 3716 | |
| 3144 | -//# sourceMappingURL=QueryErrorResetBoundary.js.map | |
| 3145 | 3717 | |
| 3718 | +//# sourceMappingURL=QueryErrorResetBoundary.mjs.map | |
| 3719 | + | |
| 3720 | + | |
| 3146 | 3721 | /***/ }), |
| 3147 | 3722 | |
| 3148 | -/***/ "./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js": | |
| 3149 | -/*!*******************************************************************************!*\ | |
| 3150 | - !*** ./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js ***! | |
| 3151 | - \*******************************************************************************/ | |
| 3723 | +/***/ "./node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs": | |
| 3724 | +/*!*****************************************************************************!*\ | |
| 3725 | + !*** ./node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs ***! | |
| 3726 | + \*****************************************************************************/ | |
| 3152 | 3727 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3153 | 3728 | |
| 3154 | 3729 | __webpack_require__.r(__webpack_exports__); |
| 3155 | 3730 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| @@ -3157,1737 +3732,330 @@ | ||
| 3157 | 3732 | /* harmony export */ getHasError: function() { return /* binding */ getHasError; }, |
| 3158 | 3733 | /* harmony export */ useClearResetErrorBoundary: function() { return /* binding */ useClearResetErrorBoundary; } |
| 3159 | 3734 | /* harmony export */ }); |
| 3160 | 3735 | /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3161 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 3162 | -"use client"; | |
| 3736 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/react-query/build/lib/utils.mjs"); | |
| 3737 | +'use client'; | |
| 3163 | 3738 | |
| 3164 | -// src/errorBoundaryUtils.ts | |
| 3165 | 3739 | |
| 3166 | 3740 | |
| 3167 | -var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => { | |
| 3168 | - if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) { | |
| 3741 | +const ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => { | |
| 3742 | + if (options.suspense || options.useErrorBoundary) { | |
| 3743 | + // Prevent retrying failed query if the error boundary has not been reset yet | |
| 3169 | 3744 | if (!errorResetBoundary.isReset()) { |
| 3170 | 3745 | options.retryOnMount = false; |
| 3171 | 3746 | } |
| 3172 | 3747 | } |
| 3173 | 3748 | }; |
| 3174 | -var useClearResetErrorBoundary = (errorResetBoundary) => { | |
| 3749 | +const useClearResetErrorBoundary = errorResetBoundary => { | |
| 3175 | 3750 | react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3176 | 3751 | errorResetBoundary.clearReset(); |
| 3177 | 3752 | }, [errorResetBoundary]); |
| 3178 | 3753 | }; |
| 3179 | -var getHasError = ({ | |
| 3754 | +const getHasError = ({ | |
| 3180 | 3755 | result, |
| 3181 | 3756 | errorResetBoundary, |
| 3182 | - throwOnError, | |
| 3183 | - query, | |
| 3184 | - suspense | |
| 3757 | + useErrorBoundary, | |
| 3758 | + query | |
| 3185 | 3759 | }) => { |
| 3186 | - return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.shouldThrowError)(throwOnError, [result.error, query])); | |
| 3760 | + return result.isError && !errorResetBoundary.isReset() && !result.isFetching && (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_1__.shouldThrowError)(useErrorBoundary, [result.error, query]); | |
| 3187 | 3761 | }; |
| 3188 | 3762 | |
| 3189 | -//# sourceMappingURL=errorBoundaryUtils.js.map | |
| 3190 | 3763 | |
| 3191 | -/***/ }), | |
| 3764 | +//# sourceMappingURL=errorBoundaryUtils.mjs.map | |
| 3192 | 3765 | |
| 3193 | -/***/ "./node_modules/@tanstack/react-query/build/modern/suspense.js": | |
| 3194 | -/*!*********************************************************************!*\ | |
| 3195 | - !*** ./node_modules/@tanstack/react-query/build/modern/suspense.js ***! | |
| 3196 | - \*********************************************************************/ | |
| 3197 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3198 | 3766 | |
| 3199 | -__webpack_require__.r(__webpack_exports__); | |
| 3200 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3201 | -/* harmony export */ defaultThrowOnError: function() { return /* binding */ defaultThrowOnError; }, | |
| 3202 | -/* harmony export */ ensureSuspenseTimers: function() { return /* binding */ ensureSuspenseTimers; }, | |
| 3203 | -/* harmony export */ fetchOptimistic: function() { return /* binding */ fetchOptimistic; }, | |
| 3204 | -/* harmony export */ shouldSuspend: function() { return /* binding */ shouldSuspend; }, | |
| 3205 | -/* harmony export */ willFetch: function() { return /* binding */ willFetch; } | |
| 3206 | -/* harmony export */ }); | |
| 3207 | -// src/suspense.ts | |
| 3208 | -var defaultThrowOnError = (_error, query) => query.state.data === void 0; | |
| 3209 | -var ensureSuspenseTimers = (defaultedOptions) => { | |
| 3210 | - if (defaultedOptions.suspense) { | |
| 3211 | - const MIN_SUSPENSE_TIME_MS = 1e3; | |
| 3212 | - const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS); | |
| 3213 | - const originalStaleTime = defaultedOptions.staleTime; | |
| 3214 | - defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime); | |
| 3215 | - if (typeof defaultedOptions.gcTime === "number") { | |
| 3216 | - defaultedOptions.gcTime = Math.max( | |
| 3217 | - defaultedOptions.gcTime, | |
| 3218 | - MIN_SUSPENSE_TIME_MS | |
| 3219 | - ); | |
| 3220 | - } | |
| 3221 | - } | |
| 3222 | -}; | |
| 3223 | -var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring; | |
| 3224 | -var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending; | |
| 3225 | -var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => { | |
| 3226 | - errorResetBoundary.clearReset(); | |
| 3227 | -}); | |
| 3228 | - | |
| 3229 | -//# sourceMappingURL=suspense.js.map | |
| 3230 | - | |
| 3231 | 3767 | /***/ }), |
| 3232 | 3768 | |
| 3233 | -/***/ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js": | |
| 3234 | -/*!*************************************************************************!*\ | |
| 3235 | - !*** ./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js ***! | |
| 3236 | - \*************************************************************************/ | |
| 3769 | +/***/ "./node_modules/@tanstack/react-query/build/lib/isRestoring.mjs": | |
| 3770 | +/*!**********************************************************************!*\ | |
| 3771 | + !*** ./node_modules/@tanstack/react-query/build/lib/isRestoring.mjs ***! | |
| 3772 | + \**********************************************************************/ | |
| 3237 | 3773 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3238 | 3774 | |
| 3239 | 3775 | __webpack_require__.r(__webpack_exports__); |
| 3240 | 3776 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3241 | -/* harmony export */ useBaseQuery: function() { return /* binding */ useBaseQuery; } | |
| 3777 | +/* harmony export */ IsRestoringProvider: function() { return /* binding */ IsRestoringProvider; }, | |
| 3778 | +/* harmony export */ useIsRestoring: function() { return /* binding */ useIsRestoring; } | |
| 3242 | 3779 | /* harmony export */ }); |
| 3243 | 3780 | /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3244 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 3245 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 3246 | -/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); | |
| 3247 | -/* harmony import */ var _QueryErrorResetBoundary_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QueryErrorResetBoundary.js */ "./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js"); | |
| 3248 | -/* harmony import */ var _errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errorBoundaryUtils.js */ "./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js"); | |
| 3249 | -/* harmony import */ var _IsRestoringProvider_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./IsRestoringProvider.js */ "./node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js"); | |
| 3250 | -/* harmony import */ var _suspense_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./suspense.js */ "./node_modules/@tanstack/react-query/build/modern/suspense.js"); | |
| 3251 | -"use client"; | |
| 3781 | +'use client'; | |
| 3252 | 3782 | |
| 3253 | -// src/useBaseQuery.ts | |
| 3254 | 3783 | |
| 3784 | +const IsRestoringContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(false); | |
| 3785 | +const useIsRestoring = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(IsRestoringContext); | |
| 3786 | +const IsRestoringProvider = IsRestoringContext.Provider; | |
| 3255 | 3787 | |
| 3256 | 3788 | |
| 3789 | +//# sourceMappingURL=isRestoring.mjs.map | |
| 3257 | 3790 | |
| 3258 | 3791 | |
| 3259 | - | |
| 3260 | - | |
| 3261 | -function useBaseQuery(options, Observer, queryClient) { | |
| 3262 | - if (true) { | |
| 3263 | - if (typeof options !== "object" || Array.isArray(options)) { | |
| 3264 | - throw new Error( | |
| 3265 | - 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object' | |
| 3266 | - ); | |
| 3267 | - } | |
| 3268 | - } | |
| 3269 | - const isRestoring = (0,_IsRestoringProvider_js__WEBPACK_IMPORTED_MODULE_6__.useIsRestoring)(); | |
| 3270 | - const errorResetBoundary = (0,_QueryErrorResetBoundary_js__WEBPACK_IMPORTED_MODULE_4__.useQueryErrorResetBoundary)(); | |
| 3271 | - const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__.useQueryClient)(queryClient); | |
| 3272 | - const defaultedOptions = client.defaultQueryOptions(options); | |
| 3273 | - client.getDefaultOptions().queries?._experimental_beforeQuery?.( | |
| 3274 | - defaultedOptions | |
| 3275 | - ); | |
| 3276 | - if (true) { | |
| 3277 | - if (!defaultedOptions.queryFn) { | |
| 3278 | - console.error( | |
| 3279 | - `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function` | |
| 3280 | - ); | |
| 3281 | - } | |
| 3282 | - } | |
| 3283 | - defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic"; | |
| 3284 | - (0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.ensureSuspenseTimers)(defaultedOptions); | |
| 3285 | - (0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.ensurePreventErrorBoundaryRetry)(defaultedOptions, errorResetBoundary); | |
| 3286 | - (0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.useClearResetErrorBoundary)(errorResetBoundary); | |
| 3287 | - const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash); | |
| 3288 | - const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState( | |
| 3289 | - () => new Observer( | |
| 3290 | - client, | |
| 3291 | - defaultedOptions | |
| 3292 | - ) | |
| 3293 | - ); | |
| 3294 | - const result = observer.getOptimisticResult(defaultedOptions); | |
| 3295 | - const shouldSubscribe = !isRestoring && options.subscribed !== false; | |
| 3296 | - react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( | |
| 3297 | - react__WEBPACK_IMPORTED_MODULE_0__.useCallback( | |
| 3298 | - (onStoreChange) => { | |
| 3299 | - const unsubscribe = shouldSubscribe ? observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batchCalls(onStoreChange)) : _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.noop; | |
| 3300 | - observer.updateResult(); | |
| 3301 | - return unsubscribe; | |
| 3302 | - }, | |
| 3303 | - [observer, shouldSubscribe] | |
| 3304 | - ), | |
| 3305 | - () => observer.getCurrentResult(), | |
| 3306 | - () => observer.getCurrentResult() | |
| 3307 | - ); | |
| 3308 | - react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { | |
| 3309 | - observer.setOptions(defaultedOptions); | |
| 3310 | - }, [defaultedOptions, observer]); | |
| 3311 | - if ((0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.shouldSuspend)(defaultedOptions, result)) { | |
| 3312 | - throw (0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.fetchOptimistic)(defaultedOptions, observer, errorResetBoundary); | |
| 3313 | - } | |
| 3314 | - if ((0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.getHasError)({ | |
| 3315 | - result, | |
| 3316 | - errorResetBoundary, | |
| 3317 | - throwOnError: defaultedOptions.throwOnError, | |
| 3318 | - query: client.getQueryCache().get(defaultedOptions.queryHash), | |
| 3319 | - suspense: defaultedOptions.suspense | |
| 3320 | - })) { | |
| 3321 | - throw result.error; | |
| 3322 | - } | |
| 3323 | - ; | |
| 3324 | - client.getDefaultOptions().queries?._experimental_afterQuery?.( | |
| 3325 | - defaultedOptions, | |
| 3326 | - result | |
| 3327 | - ); | |
| 3328 | - if (defaultedOptions.experimental_prefetchInRender && !_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.isServer && (0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.willFetch)(result, isRestoring)) { | |
| 3329 | - const promise = isNewCacheEntry ? ( | |
| 3330 | - // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted | |
| 3331 | - (0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.fetchOptimistic)(defaultedOptions, observer, errorResetBoundary) | |
| 3332 | - ) : ( | |
| 3333 | - // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in | |
| 3334 | - client.getQueryCache().get(defaultedOptions.queryHash)?.promise | |
| 3335 | - ); | |
| 3336 | - promise?.catch(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.noop).finally(() => { | |
| 3337 | - observer.updateResult(); | |
| 3338 | - }); | |
| 3339 | - } | |
| 3340 | - return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result; | |
| 3341 | -} | |
| 3342 | - | |
| 3343 | -//# sourceMappingURL=useBaseQuery.js.map | |
| 3344 | - | |
| 3345 | 3792 | /***/ }), |
| 3346 | 3793 | |
| 3347 | -/***/ "./node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js": | |
| 3348 | -/*!*****************************************************************************!*\ | |
| 3349 | - !*** ./node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js ***! | |
| 3350 | - \*****************************************************************************/ | |
| 3794 | +/***/ "./node_modules/@tanstack/react-query/build/lib/suspense.mjs": | |
| 3795 | +/*!*******************************************************************!*\ | |
| 3796 | + !*** ./node_modules/@tanstack/react-query/build/lib/suspense.mjs ***! | |
| 3797 | + \*******************************************************************/ | |
| 3351 | 3798 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3352 | 3799 | |
| 3353 | 3800 | __webpack_require__.r(__webpack_exports__); |
| 3354 | 3801 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3355 | -/* harmony export */ useInfiniteQuery: function() { return /* binding */ useInfiniteQuery; } | |
| 3802 | +/* harmony export */ ensureStaleTime: function() { return /* binding */ ensureStaleTime; }, | |
| 3803 | +/* harmony export */ fetchOptimistic: function() { return /* binding */ fetchOptimistic; }, | |
| 3804 | +/* harmony export */ shouldSuspend: function() { return /* binding */ shouldSuspend; }, | |
| 3805 | +/* harmony export */ willFetch: function() { return /* binding */ willFetch; } | |
| 3356 | 3806 | /* harmony export */ }); |
| 3357 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js"); | |
| 3358 | -/* harmony import */ var _useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./useBaseQuery.js */ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"); | |
| 3359 | -"use client"; | |
| 3807 | +const ensureStaleTime = defaultedOptions => { | |
| 3808 | + if (defaultedOptions.suspense) { | |
| 3809 | + // Always set stale time when using suspense to prevent | |
| 3810 | + // fetching again when directly mounting after suspending | |
| 3811 | + if (typeof defaultedOptions.staleTime !== 'number') { | |
| 3812 | + defaultedOptions.staleTime = 1000; | |
| 3813 | + } | |
| 3814 | + } | |
| 3815 | +}; | |
| 3816 | +const willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring; | |
| 3817 | +const shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring); | |
| 3818 | +const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({ | |
| 3819 | + data | |
| 3820 | +}) => { | |
| 3821 | + defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data); | |
| 3822 | + defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null); | |
| 3823 | +}).catch(error => { | |
| 3824 | + errorResetBoundary.clearReset(); | |
| 3825 | + defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error); | |
| 3826 | + defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error); | |
| 3827 | +}); | |
| 3360 | 3828 | |
| 3361 | -// src/useInfiniteQuery.ts | |
| 3362 | 3829 | |
| 3830 | +//# sourceMappingURL=suspense.mjs.map | |
| 3363 | 3831 | |
| 3364 | -function useInfiniteQuery(options, queryClient) { | |
| 3365 | - return (0,_useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__.useBaseQuery)( | |
| 3366 | - options, | |
| 3367 | - _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__.InfiniteQueryObserver, | |
| 3368 | - queryClient | |
| 3369 | - ); | |
| 3370 | -} | |
| 3371 | 3832 | |
| 3372 | -//# sourceMappingURL=useInfiniteQuery.js.map | |
| 3373 | - | |
| 3374 | 3833 | /***/ }), |
| 3375 | 3834 | |
| 3376 | -/***/ "./node_modules/@tanstack/react-query/build/modern/useMutation.js": | |
| 3377 | -/*!************************************************************************!*\ | |
| 3378 | - !*** ./node_modules/@tanstack/react-query/build/modern/useMutation.js ***! | |
| 3379 | - \************************************************************************/ | |
| 3835 | +/***/ "./node_modules/@tanstack/react-query/build/lib/useBaseQuery.mjs": | |
| 3836 | +/*!***********************************************************************!*\ | |
| 3837 | + !*** ./node_modules/@tanstack/react-query/build/lib/useBaseQuery.mjs ***! | |
| 3838 | + \***********************************************************************/ | |
| 3380 | 3839 | /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3381 | 3840 | |
| 3382 | 3841 | __webpack_require__.r(__webpack_exports__); |
| 3383 | 3842 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3384 | -/* harmony export */ useMutation: function() { return /* binding */ useMutation; } | |
| 3843 | +/* harmony export */ useBaseQuery: function() { return /* binding */ useBaseQuery; } | |
| 3385 | 3844 | /* harmony export */ }); |
| 3386 | 3845 | /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3387 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/mutationObserver.js"); | |
| 3388 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 3389 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 3390 | -/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); | |
| 3391 | -"use client"; | |
| 3846 | +/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 3847 | +/* harmony import */ var _useSyncExternalStore_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./useSyncExternalStore.mjs */ "./node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs"); | |
| 3848 | +/* harmony import */ var _QueryErrorResetBoundary_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QueryErrorResetBoundary.mjs */ "./node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.mjs"); | |
| 3849 | +/* harmony import */ var _QueryClientProvider_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./QueryClientProvider.mjs */ "./node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs"); | |
| 3850 | +/* harmony import */ var _isRestoring_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isRestoring.mjs */ "./node_modules/@tanstack/react-query/build/lib/isRestoring.mjs"); | |
| 3851 | +/* harmony import */ var _errorBoundaryUtils_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./errorBoundaryUtils.mjs */ "./node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs"); | |
| 3852 | +/* harmony import */ var _suspense_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./suspense.mjs */ "./node_modules/@tanstack/react-query/build/lib/suspense.mjs"); | |
| 3853 | +'use client'; | |
| 3392 | 3854 | |
| 3393 | -// src/useMutation.ts | |
| 3394 | 3855 | |
| 3395 | 3856 | |
| 3396 | 3857 | |
| 3397 | -function useMutation(options, queryClient) { | |
| 3398 | - const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_4__.useQueryClient)(queryClient); | |
| 3399 | - const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState( | |
| 3400 | - () => new _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.MutationObserver( | |
| 3401 | - client, | |
| 3402 | - options | |
| 3403 | - ) | |
| 3404 | - ); | |
| 3405 | - react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { | |
| 3406 | - observer.setOptions(options); | |
| 3407 | - }, [observer, options]); | |
| 3408 | - const result = react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( | |
| 3409 | - react__WEBPACK_IMPORTED_MODULE_0__.useCallback( | |
| 3410 | - (onStoreChange) => observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batchCalls(onStoreChange)), | |
| 3411 | - [observer] | |
| 3412 | - ), | |
| 3413 | - () => observer.getCurrentResult(), | |
| 3414 | - () => observer.getCurrentResult() | |
| 3415 | - ); | |
| 3416 | - const mutate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback( | |
| 3417 | - (variables, mutateOptions) => { | |
| 3418 | - observer.mutate(variables, mutateOptions).catch(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__.noop); | |
| 3419 | - }, | |
| 3420 | - [observer] | |
| 3421 | - ); | |
| 3422 | - if (result.error && (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__.shouldThrowError)(observer.options.throwOnError, [result.error])) { | |
| 3423 | - throw result.error; | |
| 3424 | - } | |
| 3425 | - return { ...result, mutate, mutateAsync: result.mutate }; | |
| 3426 | -} | |
| 3427 | 3858 | |
| 3428 | -//# sourceMappingURL=useMutation.js.map | |
| 3429 | 3859 | |
| 3430 | -/***/ }), | |
| 3431 | 3860 | |
| 3432 | -/***/ "./node_modules/@tanstack/react-query/build/modern/useMutationState.js": | |
| 3433 | -/*!*****************************************************************************!*\ | |
| 3434 | - !*** ./node_modules/@tanstack/react-query/build/modern/useMutationState.js ***! | |
| 3435 | - \*****************************************************************************/ | |
| 3436 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3437 | 3861 | |
| 3438 | -__webpack_require__.r(__webpack_exports__); | |
| 3439 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3440 | -/* harmony export */ useIsMutating: function() { return /* binding */ useIsMutating; }, | |
| 3441 | -/* harmony export */ useMutationState: function() { return /* binding */ useMutationState; } | |
| 3442 | -/* harmony export */ }); | |
| 3443 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 3444 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); | |
| 3445 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); | |
| 3446 | -/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); | |
| 3447 | -"use client"; | |
| 3448 | 3862 | |
| 3449 | -// src/useMutationState.ts | |
| 3450 | - | |
| 3451 | - | |
| 3452 | - | |
| 3453 | -function useIsMutating(filters, queryClient) { | |
| 3454 | - const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__.useQueryClient)(queryClient); | |
| 3455 | - return useMutationState( | |
| 3456 | - { filters: { ...filters, status: "pending" } }, | |
| 3457 | - client | |
| 3458 | - ).length; | |
| 3459 | -} | |
| 3460 | -function getResult(mutationCache, options) { | |
| 3461 | - return mutationCache.findAll(options.filters).map( | |
| 3462 | - (mutation) => options.select ? options.select(mutation) : mutation.state | |
| 3463 | - ); | |
| 3464 | -} | |
| 3465 | -function useMutationState(options = {}, queryClient) { | |
| 3466 | - const mutationCache = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__.useQueryClient)(queryClient).getMutationCache(); | |
| 3467 | - const optionsRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(options); | |
| 3468 | - const result = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null); | |
| 3469 | - if (result.current === null) { | |
| 3470 | - result.current = getResult(mutationCache, options); | |
| 3471 | - } | |
| 3472 | - react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { | |
| 3473 | - optionsRef.current = options; | |
| 3863 | +function useBaseQuery(options, Observer) { | |
| 3864 | + const queryClient = (0,_QueryClientProvider_mjs__WEBPACK_IMPORTED_MODULE_1__.useQueryClient)({ | |
| 3865 | + context: options.context | |
| 3474 | 3866 | }); |
| 3475 | - return react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( | |
| 3476 | - react__WEBPACK_IMPORTED_MODULE_0__.useCallback( | |
| 3477 | - (onStoreChange) => mutationCache.subscribe(() => { | |
| 3478 | - const nextResult = (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.replaceEqualDeep)( | |
| 3479 | - result.current, | |
| 3480 | - getResult(mutationCache, optionsRef.current) | |
| 3481 | - ); | |
| 3482 | - if (result.current !== nextResult) { | |
| 3483 | - result.current = nextResult; | |
| 3484 | - _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.notifyManager.schedule(onStoreChange); | |
| 3485 | - } | |
| 3486 | - }), | |
| 3487 | - [mutationCache] | |
| 3488 | - ), | |
| 3489 | - () => result.current, | |
| 3490 | - () => result.current | |
| 3491 | - ); | |
| 3492 | -} | |
| 3867 | + const isRestoring = (0,_isRestoring_mjs__WEBPACK_IMPORTED_MODULE_2__.useIsRestoring)(); | |
| 3868 | + const errorResetBoundary = (0,_QueryErrorResetBoundary_mjs__WEBPACK_IMPORTED_MODULE_3__.useQueryErrorResetBoundary)(); | |
| 3869 | + const defaultedOptions = queryClient.defaultQueryOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options | |
| 3493 | 3870 | |
| 3494 | -//# sourceMappingURL=useMutationState.js.map | |
| 3871 | + defaultedOptions._optimisticResults = isRestoring ? 'isRestoring' : 'optimistic'; // Include callbacks in batch renders | |
| 3495 | 3872 | |
| 3496 | -/***/ }), | |
| 3497 | - | |
| 3498 | -/***/ "./node_modules/@tanstack/react-query/build/modern/useQuery.js": | |
| 3499 | -/*!*********************************************************************!*\ | |
| 3500 | - !*** ./node_modules/@tanstack/react-query/build/modern/useQuery.js ***! | |
| 3501 | - \*********************************************************************/ | |
| 3502 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3503 | - | |
| 3504 | -__webpack_require__.r(__webpack_exports__); | |
| 3505 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3506 | -/* harmony export */ useQuery: function() { return /* binding */ useQuery; } | |
| 3507 | -/* harmony export */ }); | |
| 3508 | -/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js"); | |
| 3509 | -/* harmony import */ var _useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./useBaseQuery.js */ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"); | |
| 3510 | -"use client"; | |
| 3511 | - | |
| 3512 | -// src/useQuery.ts | |
| 3513 | - | |
| 3514 | - | |
| 3515 | -function useQuery(options, queryClient) { | |
| 3516 | - return (0,_useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__.useBaseQuery)(options, _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__.QueryObserver, queryClient); | |
| 3517 | -} | |
| 3518 | - | |
| 3519 | -//# sourceMappingURL=useQuery.js.map | |
| 3520 | - | |
| 3521 | -/***/ }), | |
| 3522 | - | |
| 3523 | -/***/ "./node_modules/react/cjs/react-jsx-runtime.development.js": | |
| 3524 | -/*!*****************************************************************!*\ | |
| 3525 | - !*** ./node_modules/react/cjs/react-jsx-runtime.development.js ***! | |
| 3526 | - \*****************************************************************/ | |
| 3527 | -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { | |
| 3528 | - | |
| 3529 | -/** | |
| 3530 | - * @license React | |
| 3531 | - * react-jsx-runtime.development.js | |
| 3532 | - * | |
| 3533 | - * Copyright (c) Facebook, Inc. and its affiliates. | |
| 3534 | - * | |
| 3535 | - * This source code is licensed under the MIT license found in the | |
| 3536 | - * LICENSE file in the root directory of this source tree. | |
| 3537 | - */ | |
| 3538 | - | |
| 3539 | - | |
| 3540 | - | |
| 3541 | -if (true) { | |
| 3542 | - (function() { | |
| 3543 | -'use strict'; | |
| 3544 | - | |
| 3545 | -var React = __webpack_require__(/*! react */ "react"); | |
| 3546 | - | |
| 3547 | -// ATTENTION | |
| 3548 | -// When adding new symbols to this file, | |
| 3549 | -// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' | |
| 3550 | -// The Symbol used to tag the ReactElement-like types. | |
| 3551 | -var REACT_ELEMENT_TYPE = Symbol.for('react.element'); | |
| 3552 | -var REACT_PORTAL_TYPE = Symbol.for('react.portal'); | |
| 3553 | -var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); | |
| 3554 | -var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); | |
| 3555 | -var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); | |
| 3556 | -var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); | |
| 3557 | -var REACT_CONTEXT_TYPE = Symbol.for('react.context'); | |
| 3558 | -var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); | |
| 3559 | -var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); | |
| 3560 | -var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); | |
| 3561 | -var REACT_MEMO_TYPE = Symbol.for('react.memo'); | |
| 3562 | -var REACT_LAZY_TYPE = Symbol.for('react.lazy'); | |
| 3563 | -var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); | |
| 3564 | -var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; | |
| 3565 | -var FAUX_ITERATOR_SYMBOL = '@@iterator'; | |
| 3566 | -function getIteratorFn(maybeIterable) { | |
| 3567 | - if (maybeIterable === null || typeof maybeIterable !== 'object') { | |
| 3568 | - return null; | |
| 3873 | + if (defaultedOptions.onError) { | |
| 3874 | + defaultedOptions.onError = _tanstack_query_core__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batchCalls(defaultedOptions.onError); | |
| 3569 | 3875 | } |
| 3570 | 3876 | |
| 3571 | - var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; | |
| 3572 | - | |
| 3573 | - if (typeof maybeIterator === 'function') { | |
| 3574 | - return maybeIterator; | |
| 3877 | + if (defaultedOptions.onSuccess) { | |
| 3878 | + defaultedOptions.onSuccess = _tanstack_query_core__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batchCalls(defaultedOptions.onSuccess); | |
| 3575 | 3879 | } |
| 3576 | 3880 | |
| 3577 | - return null; | |
| 3578 | -} | |
| 3579 | - | |
| 3580 | -var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | |
| 3581 | - | |
| 3582 | -function error(format) { | |
| 3583 | - { | |
| 3584 | - { | |
| 3585 | - for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | |
| 3586 | - args[_key2 - 1] = arguments[_key2]; | |
| 3587 | - } | |
| 3588 | - | |
| 3589 | - printWarning('error', format, args); | |
| 3590 | - } | |
| 3881 | + if (defaultedOptions.onSettled) { | |
| 3882 | + defaultedOptions.onSettled = _tanstack_query_core__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batchCalls(defaultedOptions.onSettled); | |
| 3591 | 3883 | } |
| 3592 | -} | |
| 3593 | 3884 | |
| 3594 | -function printWarning(level, format, args) { | |
| 3595 | - // When changing this logic, you might want to also | |
| 3596 | - // update consoleWithStackDev.www.js as well. | |
| 3597 | - { | |
| 3598 | - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | |
| 3599 | - var stack = ReactDebugCurrentFrame.getStackAddendum(); | |
| 3885 | + (0,_suspense_mjs__WEBPACK_IMPORTED_MODULE_5__.ensureStaleTime)(defaultedOptions); | |
| 3886 | + (0,_errorBoundaryUtils_mjs__WEBPACK_IMPORTED_MODULE_6__.ensurePreventErrorBoundaryRetry)(defaultedOptions, errorResetBoundary); | |
| 3887 | + (0,_errorBoundaryUtils_mjs__WEBPACK_IMPORTED_MODULE_6__.useClearResetErrorBoundary)(errorResetBoundary); | |
| 3888 | + const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState(() => new Observer(queryClient, defaultedOptions)); | |
| 3889 | + const result = observer.getOptimisticResult(defaultedOptions); | |
| 3890 | + (0,_useSyncExternalStore_mjs__WEBPACK_IMPORTED_MODULE_7__.useSyncExternalStore)(react__WEBPACK_IMPORTED_MODULE_0__.useCallback(onStoreChange => { | |
| 3891 | + const unsubscribe = isRestoring ? () => undefined : observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batchCalls(onStoreChange)); // Update result to make sure we did not miss any query updates | |
| 3892 | + // between creating the observer and subscribing to it. | |
| 3600 | 3893 | |
| 3601 | - if (stack !== '') { | |
| 3602 | - format += '%s'; | |
| 3603 | - args = args.concat([stack]); | |
| 3604 | - } // eslint-disable-next-line react-internal/safe-string-coercion | |
| 3894 | + observer.updateResult(); | |
| 3895 | + return unsubscribe; | |
| 3896 | + }, [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult()); | |
| 3897 | + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { | |
| 3898 | + // Do not notify on updates because of changes in the options because | |
| 3899 | + // these changes should already be reflected in the optimistic result. | |
| 3900 | + observer.setOptions(defaultedOptions, { | |
| 3901 | + listeners: false | |
| 3902 | + }); | |
| 3903 | + }, [defaultedOptions, observer]); // Handle suspense | |
| 3605 | 3904 | |
| 3905 | + if ((0,_suspense_mjs__WEBPACK_IMPORTED_MODULE_5__.shouldSuspend)(defaultedOptions, result, isRestoring)) { | |
| 3906 | + throw (0,_suspense_mjs__WEBPACK_IMPORTED_MODULE_5__.fetchOptimistic)(defaultedOptions, observer, errorResetBoundary); | |
| 3907 | + } // Handle error boundary | |
| 3606 | 3908 | |
| 3607 | - var argsWithFormat = args.map(function (item) { | |
| 3608 | - return String(item); | |
| 3609 | - }); // Careful: RN currently depends on this prefix | |
| 3610 | 3909 | |
| 3611 | - argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | |
| 3612 | - // breaks IE9: https://github.com/facebook/react/issues/13610 | |
| 3613 | - // eslint-disable-next-line react-internal/no-production-logging | |
| 3910 | + if ((0,_errorBoundaryUtils_mjs__WEBPACK_IMPORTED_MODULE_6__.getHasError)({ | |
| 3911 | + result, | |
| 3912 | + errorResetBoundary, | |
| 3913 | + useErrorBoundary: defaultedOptions.useErrorBoundary, | |
| 3914 | + query: observer.getCurrentQuery() | |
| 3915 | + })) { | |
| 3916 | + throw result.error; | |
| 3917 | + } // Handle result property usage tracking | |
| 3614 | 3918 | |
| 3615 | - Function.prototype.apply.call(console[level], console, argsWithFormat); | |
| 3616 | - } | |
| 3617 | -} | |
| 3618 | 3919 | |
| 3619 | -// ----------------------------------------------------------------------------- | |
| 3620 | - | |
| 3621 | -var enableScopeAPI = false; // Experimental Create Event Handle API. | |
| 3622 | -var enableCacheElement = false; | |
| 3623 | -var enableTransitionTracing = false; // No known bugs, but needs performance testing | |
| 3624 | - | |
| 3625 | -var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber | |
| 3626 | -// stuff. Intended to enable React core members to more easily debug scheduling | |
| 3627 | -// issues in DEV builds. | |
| 3628 | - | |
| 3629 | -var enableDebugTracing = false; // Track which Fiber(s) schedule render work. | |
| 3630 | - | |
| 3631 | -var REACT_MODULE_REFERENCE; | |
| 3632 | - | |
| 3633 | -{ | |
| 3634 | - REACT_MODULE_REFERENCE = Symbol.for('react.module.reference'); | |
| 3920 | + return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result; | |
| 3635 | 3921 | } |
| 3636 | 3922 | |
| 3637 | -function isValidElementType(type) { | |
| 3638 | - if (typeof type === 'string' || typeof type === 'function') { | |
| 3639 | - return true; | |
| 3640 | - } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). | |
| 3641 | 3923 | |
| 3924 | +//# sourceMappingURL=useBaseQuery.mjs.map | |
| 3642 | 3925 | |
| 3643 | - if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) { | |
| 3644 | - return true; | |
| 3645 | - } | |
| 3646 | 3926 | |
| 3647 | - if (typeof type === 'object' && type !== null) { | |
| 3648 | - if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object | |
| 3649 | - // types supported by any Flight configuration anywhere since | |
| 3650 | - // we don't know which Flight build this will end up being used | |
| 3651 | - // with. | |
| 3652 | - type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) { | |
| 3653 | - return true; | |
| 3654 | - } | |
| 3655 | - } | |
| 3927 | +/***/ }), | |
| 3656 | 3928 | |
| 3657 | - return false; | |
| 3658 | -} | |
| 3929 | +/***/ "./node_modules/@tanstack/react-query/build/lib/useMutation.mjs": | |
| 3930 | +/*!**********************************************************************!*\ | |
| 3931 | + !*** ./node_modules/@tanstack/react-query/build/lib/useMutation.mjs ***! | |
| 3932 | + \**********************************************************************/ | |
| 3933 | +/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3659 | 3934 | |
| 3660 | -function getWrappedName(outerType, innerType, wrapperName) { | |
| 3661 | - var displayName = outerType.displayName; | |
| 3935 | +__webpack_require__.r(__webpack_exports__); | |
| 3936 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3937 | +/* harmony export */ useMutation: function() { return /* binding */ useMutation; } | |
| 3938 | +/* harmony export */ }); | |
| 3939 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 3940 | +/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 3941 | +/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/lib/mutationObserver.mjs"); | |
| 3942 | +/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/lib/notifyManager.mjs"); | |
| 3943 | +/* harmony import */ var _useSyncExternalStore_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./useSyncExternalStore.mjs */ "./node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs"); | |
| 3944 | +/* harmony import */ var _QueryClientProvider_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./QueryClientProvider.mjs */ "./node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs"); | |
| 3945 | +/* harmony import */ var _utils_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils.mjs */ "./node_modules/@tanstack/react-query/build/lib/utils.mjs"); | |
| 3946 | +'use client'; | |
| 3662 | 3947 | |
| 3663 | - if (displayName) { | |
| 3664 | - return displayName; | |
| 3665 | - } | |
| 3666 | 3948 | |
| 3667 | - var functionName = innerType.displayName || innerType.name || ''; | |
| 3668 | - return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName; | |
| 3669 | -} // Keep in sync with react-reconciler/getComponentNameFromFiber | |
| 3670 | 3949 | |
| 3671 | 3950 | |
| 3672 | -function getContextName(type) { | |
| 3673 | - return type.displayName || 'Context'; | |
| 3674 | -} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. | |
| 3675 | 3951 | |
| 3676 | 3952 | |
| 3677 | -function getComponentNameFromType(type) { | |
| 3678 | - if (type == null) { | |
| 3679 | - // Host root, text node or just invalid type. | |
| 3680 | - return null; | |
| 3681 | - } | |
| 3953 | +function useMutation(arg1, arg2, arg3) { | |
| 3954 | + const options = (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.parseMutationArgs)(arg1, arg2, arg3); | |
| 3955 | + const queryClient = (0,_QueryClientProvider_mjs__WEBPACK_IMPORTED_MODULE_2__.useQueryClient)({ | |
| 3956 | + context: options.context | |
| 3957 | + }); | |
| 3958 | + const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState(() => new _tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__.MutationObserver(queryClient, options)); | |
| 3959 | + react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { | |
| 3960 | + observer.setOptions(options); | |
| 3961 | + }, [observer, options]); | |
| 3962 | + const result = (0,_useSyncExternalStore_mjs__WEBPACK_IMPORTED_MODULE_4__.useSyncExternalStore)(react__WEBPACK_IMPORTED_MODULE_0__.useCallback(onStoreChange => observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult()); | |
| 3963 | + const mutate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback((variables, mutateOptions) => { | |
| 3964 | + observer.mutate(variables, mutateOptions).catch(noop); | |
| 3965 | + }, [observer]); | |
| 3682 | 3966 | |
| 3683 | - { | |
| 3684 | - if (typeof type.tag === 'number') { | |
| 3685 | - error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.'); | |
| 3686 | - } | |
| 3967 | + if (result.error && (0,_utils_mjs__WEBPACK_IMPORTED_MODULE_6__.shouldThrowError)(observer.options.useErrorBoundary, [result.error])) { | |
| 3968 | + throw result.error; | |
| 3687 | 3969 | } |
| 3688 | 3970 | |
| 3689 | - if (typeof type === 'function') { | |
| 3690 | - return type.displayName || type.name || null; | |
| 3691 | - } | |
| 3692 | - | |
| 3693 | - if (typeof type === 'string') { | |
| 3694 | - return type; | |
| 3695 | - } | |
| 3696 | - | |
| 3697 | - switch (type) { | |
| 3698 | - case REACT_FRAGMENT_TYPE: | |
| 3699 | - return 'Fragment'; | |
| 3700 | - | |
| 3701 | - case REACT_PORTAL_TYPE: | |
| 3702 | - return 'Portal'; | |
| 3703 | - | |
| 3704 | - case REACT_PROFILER_TYPE: | |
| 3705 | - return 'Profiler'; | |
| 3706 | - | |
| 3707 | - case REACT_STRICT_MODE_TYPE: | |
| 3708 | - return 'StrictMode'; | |
| 3709 | - | |
| 3710 | - case REACT_SUSPENSE_TYPE: | |
| 3711 | - return 'Suspense'; | |
| 3712 | - | |
| 3713 | - case REACT_SUSPENSE_LIST_TYPE: | |
| 3714 | - return 'SuspenseList'; | |
| 3715 | - | |
| 3716 | - } | |
| 3717 | - | |
| 3718 | - if (typeof type === 'object') { | |
| 3719 | - switch (type.$$typeof) { | |
| 3720 | - case REACT_CONTEXT_TYPE: | |
| 3721 | - var context = type; | |
| 3722 | - return getContextName(context) + '.Consumer'; | |
| 3723 | - | |
| 3724 | - case REACT_PROVIDER_TYPE: | |
| 3725 | - var provider = type; | |
| 3726 | - return getContextName(provider._context) + '.Provider'; | |
| 3727 | - | |
| 3728 | - case REACT_FORWARD_REF_TYPE: | |
| 3729 | - return getWrappedName(type, type.render, 'ForwardRef'); | |
| 3730 | - | |
| 3731 | - case REACT_MEMO_TYPE: | |
| 3732 | - var outerName = type.displayName || null; | |
| 3733 | - | |
| 3734 | - if (outerName !== null) { | |
| 3735 | - return outerName; | |
| 3736 | - } | |
| 3737 | - | |
| 3738 | - return getComponentNameFromType(type.type) || 'Memo'; | |
| 3739 | - | |
| 3740 | - case REACT_LAZY_TYPE: | |
| 3741 | - { | |
| 3742 | - var lazyComponent = type; | |
| 3743 | - var payload = lazyComponent._payload; | |
| 3744 | - var init = lazyComponent._init; | |
| 3745 | - | |
| 3746 | - try { | |
| 3747 | - return getComponentNameFromType(init(payload)); | |
| 3748 | - } catch (x) { | |
| 3749 | - return null; | |
| 3750 | - } | |
| 3751 | - } | |
| 3752 | - | |
| 3753 | - // eslint-disable-next-line no-fallthrough | |
| 3754 | - } | |
| 3755 | - } | |
| 3756 | - | |
| 3757 | - return null; | |
| 3758 | -} | |
| 3759 | - | |
| 3760 | -var assign = Object.assign; | |
| 3761 | - | |
| 3762 | -// Helpers to patch console.logs to avoid logging during side-effect free | |
| 3763 | -// replaying on render function. This currently only patches the object | |
| 3764 | -// lazily which won't cover if the log function was extracted eagerly. | |
| 3765 | -// We could also eagerly patch the method. | |
| 3766 | -var disabledDepth = 0; | |
| 3767 | -var prevLog; | |
| 3768 | -var prevInfo; | |
| 3769 | -var prevWarn; | |
| 3770 | -var prevError; | |
| 3771 | -var prevGroup; | |
| 3772 | -var prevGroupCollapsed; | |
| 3773 | -var prevGroupEnd; | |
| 3774 | - | |
| 3775 | -function disabledLog() {} | |
| 3776 | - | |
| 3777 | -disabledLog.__reactDisabledLog = true; | |
| 3778 | -function disableLogs() { | |
| 3779 | - { | |
| 3780 | - if (disabledDepth === 0) { | |
| 3781 | - /* eslint-disable react-internal/no-production-logging */ | |
| 3782 | - prevLog = console.log; | |
| 3783 | - prevInfo = console.info; | |
| 3784 | - prevWarn = console.warn; | |
| 3785 | - prevError = console.error; | |
| 3786 | - prevGroup = console.group; | |
| 3787 | - prevGroupCollapsed = console.groupCollapsed; | |
| 3788 | - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 | |
| 3789 | - | |
| 3790 | - var props = { | |
| 3791 | - configurable: true, | |
| 3792 | - enumerable: true, | |
| 3793 | - value: disabledLog, | |
| 3794 | - writable: true | |
| 3795 | - }; // $FlowFixMe Flow thinks console is immutable. | |
| 3796 | - | |
| 3797 | - Object.defineProperties(console, { | |
| 3798 | - info: props, | |
| 3799 | - log: props, | |
| 3800 | - warn: props, | |
| 3801 | - error: props, | |
| 3802 | - group: props, | |
| 3803 | - groupCollapsed: props, | |
| 3804 | - groupEnd: props | |
| 3805 | - }); | |
| 3806 | - /* eslint-enable react-internal/no-production-logging */ | |
| 3807 | - } | |
| 3808 | - | |
| 3809 | - disabledDepth++; | |
| 3810 | - } | |
| 3811 | -} | |
| 3812 | -function reenableLogs() { | |
| 3813 | - { | |
| 3814 | - disabledDepth--; | |
| 3815 | - | |
| 3816 | - if (disabledDepth === 0) { | |
| 3817 | - /* eslint-disable react-internal/no-production-logging */ | |
| 3818 | - var props = { | |
| 3819 | - configurable: true, | |
| 3820 | - enumerable: true, | |
| 3821 | - writable: true | |
| 3822 | - }; // $FlowFixMe Flow thinks console is immutable. | |
| 3823 | - | |
| 3824 | - Object.defineProperties(console, { | |
| 3825 | - log: assign({}, props, { | |
| 3826 | - value: prevLog | |
| 3827 | - }), | |
| 3828 | - info: assign({}, props, { | |
| 3829 | - value: prevInfo | |
| 3830 | - }), | |
| 3831 | - warn: assign({}, props, { | |
| 3832 | - value: prevWarn | |
| 3833 | - }), | |
| 3834 | - error: assign({}, props, { | |
| 3835 | - value: prevError | |
| 3836 | - }), | |
| 3837 | - group: assign({}, props, { | |
| 3838 | - value: prevGroup | |
| 3839 | - }), | |
| 3840 | - groupCollapsed: assign({}, props, { | |
| 3841 | - value: prevGroupCollapsed | |
| 3842 | - }), | |
| 3843 | - groupEnd: assign({}, props, { | |
| 3844 | - value: prevGroupEnd | |
| 3845 | - }) | |
| 3846 | - }); | |
| 3847 | - /* eslint-enable react-internal/no-production-logging */ | |
| 3848 | - } | |
| 3849 | - | |
| 3850 | - if (disabledDepth < 0) { | |
| 3851 | - error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); | |
| 3852 | - } | |
| 3853 | - } | |
| 3854 | -} | |
| 3855 | - | |
| 3856 | -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; | |
| 3857 | -var prefix; | |
| 3858 | -function describeBuiltInComponentFrame(name, source, ownerFn) { | |
| 3859 | - { | |
| 3860 | - if (prefix === undefined) { | |
| 3861 | - // Extract the VM specific prefix used by each line. | |
| 3862 | - try { | |
| 3863 | - throw Error(); | |
| 3864 | - } catch (x) { | |
| 3865 | - var match = x.stack.trim().match(/\n( *(at )?)/); | |
| 3866 | - prefix = match && match[1] || ''; | |
| 3867 | - } | |
| 3868 | - } // We use the prefix to ensure our stacks line up with native stack frames. | |
| 3869 | - | |
| 3870 | - | |
| 3871 | - return '\n' + prefix + name; | |
| 3872 | - } | |
| 3873 | -} | |
| 3874 | -var reentry = false; | |
| 3875 | -var componentFrameCache; | |
| 3876 | - | |
| 3877 | -{ | |
| 3878 | - var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; | |
| 3879 | - componentFrameCache = new PossiblyWeakMap(); | |
| 3880 | -} | |
| 3881 | - | |
| 3882 | -function describeNativeComponentFrame(fn, construct) { | |
| 3883 | - // If something asked for a stack inside a fake render, it should get ignored. | |
| 3884 | - if ( !fn || reentry) { | |
| 3885 | - return ''; | |
| 3886 | - } | |
| 3887 | - | |
| 3888 | - { | |
| 3889 | - var frame = componentFrameCache.get(fn); | |
| 3890 | - | |
| 3891 | - if (frame !== undefined) { | |
| 3892 | - return frame; | |
| 3893 | - } | |
| 3894 | - } | |
| 3895 | - | |
| 3896 | - var control; | |
| 3897 | - reentry = true; | |
| 3898 | - var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. | |
| 3899 | - | |
| 3900 | - Error.prepareStackTrace = undefined; | |
| 3901 | - var previousDispatcher; | |
| 3902 | - | |
| 3903 | - { | |
| 3904 | - previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function | |
| 3905 | - // for warnings. | |
| 3906 | - | |
| 3907 | - ReactCurrentDispatcher.current = null; | |
| 3908 | - disableLogs(); | |
| 3909 | - } | |
| 3910 | - | |
| 3911 | - try { | |
| 3912 | - // This should throw. | |
| 3913 | - if (construct) { | |
| 3914 | - // Something should be setting the props in the constructor. | |
| 3915 | - var Fake = function () { | |
| 3916 | - throw Error(); | |
| 3917 | - }; // $FlowFixMe | |
| 3918 | - | |
| 3919 | - | |
| 3920 | - Object.defineProperty(Fake.prototype, 'props', { | |
| 3921 | - set: function () { | |
| 3922 | - // We use a throwing setter instead of frozen or non-writable props | |
| 3923 | - // because that won't throw in a non-strict mode function. | |
| 3924 | - throw Error(); | |
| 3925 | - } | |
| 3926 | - }); | |
| 3927 | - | |
| 3928 | - if (typeof Reflect === 'object' && Reflect.construct) { | |
| 3929 | - // We construct a different control for this case to include any extra | |
| 3930 | - // frames added by the construct call. | |
| 3931 | - try { | |
| 3932 | - Reflect.construct(Fake, []); | |
| 3933 | - } catch (x) { | |
| 3934 | - control = x; | |
| 3935 | - } | |
| 3936 | - | |
| 3937 | - Reflect.construct(fn, [], Fake); | |
| 3938 | - } else { | |
| 3939 | - try { | |
| 3940 | - Fake.call(); | |
| 3941 | - } catch (x) { | |
| 3942 | - control = x; | |
| 3943 | - } | |
| 3944 | - | |
| 3945 | - fn.call(Fake.prototype); | |
| 3946 | - } | |
| 3947 | - } else { | |
| 3948 | - try { | |
| 3949 | - throw Error(); | |
| 3950 | - } catch (x) { | |
| 3951 | - control = x; | |
| 3952 | - } | |
| 3953 | - | |
| 3954 | - fn(); | |
| 3955 | - } | |
| 3956 | - } catch (sample) { | |
| 3957 | - // This is inlined manually because closure doesn't do it for us. | |
| 3958 | - if (sample && control && typeof sample.stack === 'string') { | |
| 3959 | - // This extracts the first frame from the sample that isn't also in the control. | |
| 3960 | - // Skipping one frame that we assume is the frame that calls the two. | |
| 3961 | - var sampleLines = sample.stack.split('\n'); | |
| 3962 | - var controlLines = control.stack.split('\n'); | |
| 3963 | - var s = sampleLines.length - 1; | |
| 3964 | - var c = controlLines.length - 1; | |
| 3965 | - | |
| 3966 | - while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { | |
| 3967 | - // We expect at least one stack frame to be shared. | |
| 3968 | - // Typically this will be the root most one. However, stack frames may be | |
| 3969 | - // cut off due to maximum stack limits. In this case, one maybe cut off | |
| 3970 | - // earlier than the other. We assume that the sample is longer or the same | |
| 3971 | - // and there for cut off earlier. So we should find the root most frame in | |
| 3972 | - // the sample somewhere in the control. | |
| 3973 | - c--; | |
| 3974 | - } | |
| 3975 | - | |
| 3976 | - for (; s >= 1 && c >= 0; s--, c--) { | |
| 3977 | - // Next we find the first one that isn't the same which should be the | |
| 3978 | - // frame that called our sample function and the control. | |
| 3979 | - if (sampleLines[s] !== controlLines[c]) { | |
| 3980 | - // In V8, the first line is describing the message but other VMs don't. | |
| 3981 | - // If we're about to return the first line, and the control is also on the same | |
| 3982 | - // line, that's a pretty good indicator that our sample threw at same line as | |
| 3983 | - // the control. I.e. before we entered the sample frame. So we ignore this result. | |
| 3984 | - // This can happen if you passed a class to function component, or non-function. | |
| 3985 | - if (s !== 1 || c !== 1) { | |
| 3986 | - do { | |
| 3987 | - s--; | |
| 3988 | - c--; // We may still have similar intermediate frames from the construct call. | |
| 3989 | - // The next one that isn't the same should be our match though. | |
| 3990 | - | |
| 3991 | - if (c < 0 || sampleLines[s] !== controlLines[c]) { | |
| 3992 | - // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. | |
| 3993 | - var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>" | |
| 3994 | - // but we have a user-provided "displayName" | |
| 3995 | - // splice it in to make the stack more readable. | |
| 3996 | - | |
| 3997 | - | |
| 3998 | - if (fn.displayName && _frame.includes('<anonymous>')) { | |
| 3999 | - _frame = _frame.replace('<anonymous>', fn.displayName); | |
| 4000 | - } | |
| 4001 | - | |
| 4002 | - { | |
| 4003 | - if (typeof fn === 'function') { | |
| 4004 | - componentFrameCache.set(fn, _frame); | |
| 4005 | - } | |
| 4006 | - } // Return the line we found. | |
| 4007 | - | |
| 4008 | - | |
| 4009 | - return _frame; | |
| 4010 | - } | |
| 4011 | - } while (s >= 1 && c >= 0); | |
| 4012 | - } | |
| 4013 | - | |
| 4014 | - break; | |
| 4015 | - } | |
| 4016 | - } | |
| 4017 | - } | |
| 4018 | - } finally { | |
| 4019 | - reentry = false; | |
| 4020 | - | |
| 4021 | - { | |
| 4022 | - ReactCurrentDispatcher.current = previousDispatcher; | |
| 4023 | - reenableLogs(); | |
| 4024 | - } | |
| 4025 | - | |
| 4026 | - Error.prepareStackTrace = previousPrepareStackTrace; | |
| 4027 | - } // Fallback to just using the name if we couldn't make it throw. | |
| 4028 | - | |
| 4029 | - | |
| 4030 | - var name = fn ? fn.displayName || fn.name : ''; | |
| 4031 | - var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; | |
| 4032 | - | |
| 4033 | - { | |
| 4034 | - if (typeof fn === 'function') { | |
| 4035 | - componentFrameCache.set(fn, syntheticFrame); | |
| 4036 | - } | |
| 4037 | - } | |
| 4038 | - | |
| 4039 | - return syntheticFrame; | |
| 4040 | -} | |
| 4041 | -function describeFunctionComponentFrame(fn, source, ownerFn) { | |
| 4042 | - { | |
| 4043 | - return describeNativeComponentFrame(fn, false); | |
| 4044 | - } | |
| 4045 | -} | |
| 4046 | - | |
| 4047 | -function shouldConstruct(Component) { | |
| 4048 | - var prototype = Component.prototype; | |
| 4049 | - return !!(prototype && prototype.isReactComponent); | |
| 4050 | -} | |
| 4051 | - | |
| 4052 | -function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { | |
| 4053 | - | |
| 4054 | - if (type == null) { | |
| 4055 | - return ''; | |
| 4056 | - } | |
| 4057 | - | |
| 4058 | - if (typeof type === 'function') { | |
| 4059 | - { | |
| 4060 | - return describeNativeComponentFrame(type, shouldConstruct(type)); | |
| 4061 | - } | |
| 4062 | - } | |
| 4063 | - | |
| 4064 | - if (typeof type === 'string') { | |
| 4065 | - return describeBuiltInComponentFrame(type); | |
| 4066 | - } | |
| 4067 | - | |
| 4068 | - switch (type) { | |
| 4069 | - case REACT_SUSPENSE_TYPE: | |
| 4070 | - return describeBuiltInComponentFrame('Suspense'); | |
| 4071 | - | |
| 4072 | - case REACT_SUSPENSE_LIST_TYPE: | |
| 4073 | - return describeBuiltInComponentFrame('SuspenseList'); | |
| 4074 | - } | |
| 4075 | - | |
| 4076 | - if (typeof type === 'object') { | |
| 4077 | - switch (type.$$typeof) { | |
| 4078 | - case REACT_FORWARD_REF_TYPE: | |
| 4079 | - return describeFunctionComponentFrame(type.render); | |
| 4080 | - | |
| 4081 | - case REACT_MEMO_TYPE: | |
| 4082 | - // Memo may contain any component type so we recursively resolve it. | |
| 4083 | - return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); | |
| 4084 | - | |
| 4085 | - case REACT_LAZY_TYPE: | |
| 4086 | - { | |
| 4087 | - var lazyComponent = type; | |
| 4088 | - var payload = lazyComponent._payload; | |
| 4089 | - var init = lazyComponent._init; | |
| 4090 | - | |
| 4091 | - try { | |
| 4092 | - // Lazy may contain any component type so we recursively resolve it. | |
| 4093 | - return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); | |
| 4094 | - } catch (x) {} | |
| 4095 | - } | |
| 4096 | - } | |
| 4097 | - } | |
| 4098 | - | |
| 4099 | - return ''; | |
| 4100 | -} | |
| 4101 | - | |
| 4102 | -var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| 4103 | - | |
| 4104 | -var loggedTypeFailures = {}; | |
| 4105 | -var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | |
| 4106 | - | |
| 4107 | -function setCurrentlyValidatingElement(element) { | |
| 4108 | - { | |
| 4109 | - if (element) { | |
| 4110 | - var owner = element._owner; | |
| 4111 | - var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); | |
| 4112 | - ReactDebugCurrentFrame.setExtraStackFrame(stack); | |
| 4113 | - } else { | |
| 4114 | - ReactDebugCurrentFrame.setExtraStackFrame(null); | |
| 4115 | - } | |
| 4116 | - } | |
| 4117 | -} | |
| 4118 | - | |
| 4119 | -function checkPropTypes(typeSpecs, values, location, componentName, element) { | |
| 4120 | - { | |
| 4121 | - // $FlowFixMe This is okay but Flow doesn't know it. | |
| 4122 | - var has = Function.call.bind(hasOwnProperty); | |
| 4123 | - | |
| 4124 | - for (var typeSpecName in typeSpecs) { | |
| 4125 | - if (has(typeSpecs, typeSpecName)) { | |
| 4126 | - var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to | |
| 4127 | - // fail the render phase where it didn't fail before. So we log it. | |
| 4128 | - // After these have been cleaned up, we'll let them throw. | |
| 4129 | - | |
| 4130 | - try { | |
| 4131 | - // This is intentionally an invariant that gets caught. It's the same | |
| 4132 | - // behavior as without this statement except with a better message. | |
| 4133 | - if (typeof typeSpecs[typeSpecName] !== 'function') { | |
| 4134 | - // eslint-disable-next-line react-internal/prod-error-codes | |
| 4135 | - var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); | |
| 4136 | - err.name = 'Invariant Violation'; | |
| 4137 | - throw err; | |
| 4138 | - } | |
| 4139 | - | |
| 4140 | - error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); | |
| 4141 | - } catch (ex) { | |
| 4142 | - error$1 = ex; | |
| 4143 | - } | |
| 4144 | - | |
| 4145 | - if (error$1 && !(error$1 instanceof Error)) { | |
| 4146 | - setCurrentlyValidatingElement(element); | |
| 4147 | - | |
| 4148 | - error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); | |
| 4149 | - | |
| 4150 | - setCurrentlyValidatingElement(null); | |
| 4151 | - } | |
| 4152 | - | |
| 4153 | - if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { | |
| 4154 | - // Only monitor this failure once because there tends to be a lot of the | |
| 4155 | - // same error. | |
| 4156 | - loggedTypeFailures[error$1.message] = true; | |
| 4157 | - setCurrentlyValidatingElement(element); | |
| 4158 | - | |
| 4159 | - error('Failed %s type: %s', location, error$1.message); | |
| 4160 | - | |
| 4161 | - setCurrentlyValidatingElement(null); | |
| 4162 | - } | |
| 4163 | - } | |
| 4164 | - } | |
| 4165 | - } | |
| 4166 | -} | |
| 4167 | - | |
| 4168 | -var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare | |
| 4169 | - | |
| 4170 | -function isArray(a) { | |
| 4171 | - return isArrayImpl(a); | |
| 4172 | -} | |
| 4173 | - | |
| 4174 | -/* | |
| 4175 | - * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol | |
| 4176 | - * and Temporal.* types. See https://github.com/facebook/react/pull/22064. | |
| 4177 | - * | |
| 4178 | - * The functions in this module will throw an easier-to-understand, | |
| 4179 | - * easier-to-debug exception with a clear errors message message explaining the | |
| 4180 | - * problem. (Instead of a confusing exception thrown inside the implementation | |
| 4181 | - * of the `value` object). | |
| 4182 | - */ | |
| 4183 | -// $FlowFixMe only called in DEV, so void return is not possible. | |
| 4184 | -function typeName(value) { | |
| 4185 | - { | |
| 4186 | - // toStringTag is needed for namespaced types like Temporal.Instant | |
| 4187 | - var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag; | |
| 4188 | - var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; | |
| 4189 | - return type; | |
| 4190 | - } | |
| 4191 | -} // $FlowFixMe only called in DEV, so void return is not possible. | |
| 4192 | - | |
| 4193 | - | |
| 4194 | -function willCoercionThrow(value) { | |
| 4195 | - { | |
| 4196 | - try { | |
| 4197 | - testStringCoercion(value); | |
| 4198 | - return false; | |
| 4199 | - } catch (e) { | |
| 4200 | - return true; | |
| 4201 | - } | |
| 4202 | - } | |
| 4203 | -} | |
| 4204 | - | |
| 4205 | -function testStringCoercion(value) { | |
| 4206 | - // If you ended up here by following an exception call stack, here's what's | |
| 4207 | - // happened: you supplied an object or symbol value to React (as a prop, key, | |
| 4208 | - // DOM attribute, CSS property, string ref, etc.) and when React tried to | |
| 4209 | - // coerce it to a string using `'' + value`, an exception was thrown. | |
| 4210 | - // | |
| 4211 | - // The most common types that will cause this exception are `Symbol` instances | |
| 4212 | - // and Temporal objects like `Temporal.Instant`. But any object that has a | |
| 4213 | - // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this | |
| 4214 | - // exception. (Library authors do this to prevent users from using built-in | |
| 4215 | - // numeric operators like `+` or comparison operators like `>=` because custom | |
| 4216 | - // methods are needed to perform accurate arithmetic or comparison.) | |
| 4217 | - // | |
| 4218 | - // To fix the problem, coerce this object or symbol value to a string before | |
| 4219 | - // passing it to React. The most reliable way is usually `String(value)`. | |
| 4220 | - // | |
| 4221 | - // To find which value is throwing, check the browser or debugger console. | |
| 4222 | - // Before this exception was thrown, there should be `console.error` output | |
| 4223 | - // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the | |
| 4224 | - // problem and how that type was used: key, atrribute, input value prop, etc. | |
| 4225 | - // In most cases, this console output also shows the component and its | |
| 4226 | - // ancestor components where the exception happened. | |
| 4227 | - // | |
| 4228 | - // eslint-disable-next-line react-internal/safe-string-coercion | |
| 4229 | - return '' + value; | |
| 4230 | -} | |
| 4231 | -function checkKeyStringCoercion(value) { | |
| 4232 | - { | |
| 4233 | - if (willCoercionThrow(value)) { | |
| 4234 | - error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value)); | |
| 4235 | - | |
| 4236 | - return testStringCoercion(value); // throw (to help callers find troubleshooting comments) | |
| 4237 | - } | |
| 4238 | - } | |
| 4239 | -} | |
| 4240 | - | |
| 4241 | -var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | |
| 4242 | -var RESERVED_PROPS = { | |
| 4243 | - key: true, | |
| 4244 | - ref: true, | |
| 4245 | - __self: true, | |
| 4246 | - __source: true | |
| 4247 | -}; | |
| 4248 | -var specialPropKeyWarningShown; | |
| 4249 | -var specialPropRefWarningShown; | |
| 4250 | -var didWarnAboutStringRefs; | |
| 4251 | - | |
| 4252 | -{ | |
| 4253 | - didWarnAboutStringRefs = {}; | |
| 4254 | -} | |
| 4255 | - | |
| 4256 | -function hasValidRef(config) { | |
| 4257 | - { | |
| 4258 | - if (hasOwnProperty.call(config, 'ref')) { | |
| 4259 | - var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; | |
| 4260 | - | |
| 4261 | - if (getter && getter.isReactWarning) { | |
| 4262 | - return false; | |
| 4263 | - } | |
| 4264 | - } | |
| 4265 | - } | |
| 4266 | - | |
| 4267 | - return config.ref !== undefined; | |
| 4268 | -} | |
| 4269 | - | |
| 4270 | -function hasValidKey(config) { | |
| 4271 | - { | |
| 4272 | - if (hasOwnProperty.call(config, 'key')) { | |
| 4273 | - var getter = Object.getOwnPropertyDescriptor(config, 'key').get; | |
| 4274 | - | |
| 4275 | - if (getter && getter.isReactWarning) { | |
| 4276 | - return false; | |
| 4277 | - } | |
| 4278 | - } | |
| 4279 | - } | |
| 4280 | - | |
| 4281 | - return config.key !== undefined; | |
| 4282 | -} | |
| 4283 | - | |
| 4284 | -function warnIfStringRefCannotBeAutoConverted(config, self) { | |
| 4285 | - { | |
| 4286 | - if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) { | |
| 4287 | - var componentName = getComponentNameFromType(ReactCurrentOwner.current.type); | |
| 4288 | - | |
| 4289 | - if (!didWarnAboutStringRefs[componentName]) { | |
| 4290 | - error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref); | |
| 4291 | - | |
| 4292 | - didWarnAboutStringRefs[componentName] = true; | |
| 4293 | - } | |
| 4294 | - } | |
| 4295 | - } | |
| 4296 | -} | |
| 4297 | - | |
| 4298 | -function defineKeyPropWarningGetter(props, displayName) { | |
| 4299 | - { | |
| 4300 | - var warnAboutAccessingKey = function () { | |
| 4301 | - if (!specialPropKeyWarningShown) { | |
| 4302 | - specialPropKeyWarningShown = true; | |
| 4303 | - | |
| 4304 | - error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); | |
| 4305 | - } | |
| 4306 | - }; | |
| 4307 | - | |
| 4308 | - warnAboutAccessingKey.isReactWarning = true; | |
| 4309 | - Object.defineProperty(props, 'key', { | |
| 4310 | - get: warnAboutAccessingKey, | |
| 4311 | - configurable: true | |
| 4312 | - }); | |
| 4313 | - } | |
| 4314 | -} | |
| 4315 | - | |
| 4316 | -function defineRefPropWarningGetter(props, displayName) { | |
| 4317 | - { | |
| 4318 | - var warnAboutAccessingRef = function () { | |
| 4319 | - if (!specialPropRefWarningShown) { | |
| 4320 | - specialPropRefWarningShown = true; | |
| 4321 | - | |
| 4322 | - error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); | |
| 4323 | - } | |
| 4324 | - }; | |
| 4325 | - | |
| 4326 | - warnAboutAccessingRef.isReactWarning = true; | |
| 4327 | - Object.defineProperty(props, 'ref', { | |
| 4328 | - get: warnAboutAccessingRef, | |
| 4329 | - configurable: true | |
| 4330 | - }); | |
| 4331 | - } | |
| 4332 | -} | |
| 4333 | -/** | |
| 4334 | - * Factory method to create a new React element. This no longer adheres to | |
| 4335 | - * the class pattern, so do not use new to call it. Also, instanceof check | |
| 4336 | - * will not work. Instead test $$typeof field against Symbol.for('react.element') to check | |
| 4337 | - * if something is a React Element. | |
| 4338 | - * | |
| 4339 | - * @param {*} type | |
| 4340 | - * @param {*} props | |
| 4341 | - * @param {*} key | |
| 4342 | - * @param {string|object} ref | |
| 4343 | - * @param {*} owner | |
| 4344 | - * @param {*} self A *temporary* helper to detect places where `this` is | |
| 4345 | - * different from the `owner` when React.createElement is called, so that we | |
| 4346 | - * can warn. We want to get rid of owner and replace string `ref`s with arrow | |
| 4347 | - * functions, and as long as `this` and owner are the same, there will be no | |
| 4348 | - * change in behavior. | |
| 4349 | - * @param {*} source An annotation object (added by a transpiler or otherwise) | |
| 4350 | - * indicating filename, line number, and/or other information. | |
| 4351 | - * @internal | |
| 4352 | - */ | |
| 4353 | - | |
| 4354 | - | |
| 4355 | -var ReactElement = function (type, key, ref, self, source, owner, props) { | |
| 4356 | - var element = { | |
| 4357 | - // This tag allows us to uniquely identify this as a React Element | |
| 4358 | - $$typeof: REACT_ELEMENT_TYPE, | |
| 4359 | - // Built-in properties that belong on the element | |
| 4360 | - type: type, | |
| 4361 | - key: key, | |
| 4362 | - ref: ref, | |
| 4363 | - props: props, | |
| 4364 | - // Record the component responsible for creating this element. | |
| 4365 | - _owner: owner | |
| 3971 | + return { ...result, | |
| 3972 | + mutate, | |
| 3973 | + mutateAsync: result.mutate | |
| 4366 | 3974 | }; |
| 3975 | +} // eslint-disable-next-line @typescript-eslint/no-empty-function | |
| 4367 | 3976 | |
| 4368 | - { | |
| 4369 | - // The validation flag is currently mutative. We put it on | |
| 4370 | - // an external backing store so that we can freeze the whole object. | |
| 4371 | - // This can be replaced with a WeakMap once they are implemented in | |
| 4372 | - // commonly used development environments. | |
| 4373 | - element._store = {}; // To make comparing ReactElements easier for testing purposes, we make | |
| 4374 | - // the validation flag non-enumerable (where possible, which should | |
| 4375 | - // include every environment we run tests in), so the test framework | |
| 4376 | - // ignores it. | |
| 3977 | +function noop() {} | |
| 4377 | 3978 | |
| 4378 | - Object.defineProperty(element._store, 'validated', { | |
| 4379 | - configurable: false, | |
| 4380 | - enumerable: false, | |
| 4381 | - writable: true, | |
| 4382 | - value: false | |
| 4383 | - }); // self and source are DEV only properties. | |
| 4384 | 3979 | |
| 4385 | - Object.defineProperty(element, '_self', { | |
| 4386 | - configurable: false, | |
| 4387 | - enumerable: false, | |
| 4388 | - writable: false, | |
| 4389 | - value: self | |
| 4390 | - }); // Two elements created in two different places should be considered | |
| 4391 | - // equal for testing purposes and therefore we hide it from enumeration. | |
| 3980 | +//# sourceMappingURL=useMutation.mjs.map | |
| 4392 | 3981 | |
| 4393 | - Object.defineProperty(element, '_source', { | |
| 4394 | - configurable: false, | |
| 4395 | - enumerable: false, | |
| 4396 | - writable: false, | |
| 4397 | - value: source | |
| 4398 | - }); | |
| 4399 | 3982 | |
| 4400 | - if (Object.freeze) { | |
| 4401 | - Object.freeze(element.props); | |
| 4402 | - Object.freeze(element); | |
| 4403 | - } | |
| 4404 | - } | |
| 3983 | +/***/ }), | |
| 4405 | 3984 | |
| 4406 | - return element; | |
| 4407 | -}; | |
| 4408 | -/** | |
| 4409 | - * https://github.com/reactjs/rfcs/pull/107 | |
| 4410 | - * @param {*} type | |
| 4411 | - * @param {object} props | |
| 4412 | - * @param {string} key | |
| 4413 | - */ | |
| 3985 | +/***/ "./node_modules/@tanstack/react-query/build/lib/useQuery.mjs": | |
| 3986 | +/*!*******************************************************************!*\ | |
| 3987 | + !*** ./node_modules/@tanstack/react-query/build/lib/useQuery.mjs ***! | |
| 3988 | + \*******************************************************************/ | |
| 3989 | +/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 4414 | 3990 | |
| 4415 | -function jsxDEV(type, config, maybeKey, source, self) { | |
| 4416 | - { | |
| 4417 | - var propName; // Reserved names are extracted | |
| 3991 | +__webpack_require__.r(__webpack_exports__); | |
| 3992 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3993 | +/* harmony export */ useQuery: function() { return /* binding */ useQuery; } | |
| 3994 | +/* harmony export */ }); | |
| 3995 | +/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/lib/utils.mjs"); | |
| 3996 | +/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/lib/queryObserver.mjs"); | |
| 3997 | +/* harmony import */ var _useBaseQuery_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./useBaseQuery.mjs */ "./node_modules/@tanstack/react-query/build/lib/useBaseQuery.mjs"); | |
| 3998 | +'use client'; | |
| 4418 | 3999 | |
| 4419 | - var props = {}; | |
| 4420 | - var key = null; | |
| 4421 | - var ref = null; // Currently, key can be spread in as a prop. This causes a potential | |
| 4422 | - // issue if key is also explicitly declared (ie. <div {...props} key="Hi" /> | |
| 4423 | - // or <div key="Hi" {...props} /> ). We want to deprecate key spread, | |
| 4424 | - // but as an intermediary step, we will use jsxDEV for everything except | |
| 4425 | - // <div {...props} key="Hi" />, because we aren't currently able to tell if | |
| 4426 | - // key is explicitly declared to be undefined or not. | |
| 4427 | 4000 | |
| 4428 | - if (maybeKey !== undefined) { | |
| 4429 | - { | |
| 4430 | - checkKeyStringCoercion(maybeKey); | |
| 4431 | - } | |
| 4432 | 4001 | |
| 4433 | - key = '' + maybeKey; | |
| 4434 | - } | |
| 4435 | - | |
| 4436 | - if (hasValidKey(config)) { | |
| 4437 | - { | |
| 4438 | - checkKeyStringCoercion(config.key); | |
| 4439 | - } | |
| 4440 | - | |
| 4441 | - key = '' + config.key; | |
| 4442 | - } | |
| 4443 | - | |
| 4444 | - if (hasValidRef(config)) { | |
| 4445 | - ref = config.ref; | |
| 4446 | - warnIfStringRefCannotBeAutoConverted(config, self); | |
| 4447 | - } // Remaining properties are added to a new props object | |
| 4448 | - | |
| 4449 | - | |
| 4450 | - for (propName in config) { | |
| 4451 | - if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { | |
| 4452 | - props[propName] = config[propName]; | |
| 4453 | - } | |
| 4454 | - } // Resolve default props | |
| 4455 | - | |
| 4456 | - | |
| 4457 | - if (type && type.defaultProps) { | |
| 4458 | - var defaultProps = type.defaultProps; | |
| 4459 | - | |
| 4460 | - for (propName in defaultProps) { | |
| 4461 | - if (props[propName] === undefined) { | |
| 4462 | - props[propName] = defaultProps[propName]; | |
| 4463 | - } | |
| 4464 | - } | |
| 4465 | - } | |
| 4466 | - | |
| 4467 | - if (key || ref) { | |
| 4468 | - var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; | |
| 4469 | - | |
| 4470 | - if (key) { | |
| 4471 | - defineKeyPropWarningGetter(props, displayName); | |
| 4472 | - } | |
| 4473 | - | |
| 4474 | - if (ref) { | |
| 4475 | - defineRefPropWarningGetter(props, displayName); | |
| 4476 | - } | |
| 4477 | - } | |
| 4478 | - | |
| 4479 | - return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); | |
| 4480 | - } | |
| 4002 | +function useQuery(arg1, arg2, arg3) { | |
| 4003 | + const parsedOptions = (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__.parseQueryArgs)(arg1, arg2, arg3); | |
| 4004 | + return (0,_useBaseQuery_mjs__WEBPACK_IMPORTED_MODULE_1__.useBaseQuery)(parsedOptions, _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.QueryObserver); | |
| 4481 | 4005 | } |
| 4482 | 4006 | |
| 4483 | -var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; | |
| 4484 | -var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; | |
| 4485 | 4007 | |
| 4486 | -function setCurrentlyValidatingElement$1(element) { | |
| 4487 | - { | |
| 4488 | - if (element) { | |
| 4489 | - var owner = element._owner; | |
| 4490 | - var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); | |
| 4491 | - ReactDebugCurrentFrame$1.setExtraStackFrame(stack); | |
| 4492 | - } else { | |
| 4493 | - ReactDebugCurrentFrame$1.setExtraStackFrame(null); | |
| 4494 | - } | |
| 4495 | - } | |
| 4496 | -} | |
| 4008 | +//# sourceMappingURL=useQuery.mjs.map | |
| 4497 | 4009 | |
| 4498 | -var propTypesMisspellWarningShown; | |
| 4499 | 4010 | |
| 4500 | -{ | |
| 4501 | - propTypesMisspellWarningShown = false; | |
| 4502 | -} | |
| 4503 | -/** | |
| 4504 | - * Verifies the object is a ReactElement. | |
| 4505 | - * See https://reactjs.org/docs/react-api.html#isvalidelement | |
| 4506 | - * @param {?object} object | |
| 4507 | - * @return {boolean} True if `object` is a ReactElement. | |
| 4508 | - * @final | |
| 4509 | - */ | |
| 4011 | +/***/ }), | |
| 4510 | 4012 | |
| 4013 | +/***/ "./node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs": | |
| 4014 | +/*!*******************************************************************************!*\ | |
| 4015 | + !*** ./node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs ***! | |
| 4016 | + \*******************************************************************************/ | |
| 4017 | +/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 4511 | 4018 | |
| 4512 | -function isValidElement(object) { | |
| 4513 | - { | |
| 4514 | - return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; | |
| 4515 | - } | |
| 4516 | -} | |
| 4019 | +__webpack_require__.r(__webpack_exports__); | |
| 4020 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 4021 | +/* harmony export */ useSyncExternalStore: function() { return /* binding */ useSyncExternalStore; } | |
| 4022 | +/* harmony export */ }); | |
| 4023 | +/* harmony import */ var use_sync_external_store_shim_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! use-sync-external-store/shim/index.js */ "./node_modules/use-sync-external-store/shim/index.js"); | |
| 4024 | +'use client'; | |
| 4517 | 4025 | |
| 4518 | -function getDeclarationErrorAddendum() { | |
| 4519 | - { | |
| 4520 | - if (ReactCurrentOwner$1.current) { | |
| 4521 | - var name = getComponentNameFromType(ReactCurrentOwner$1.current.type); | |
| 4522 | 4026 | |
| 4523 | - if (name) { | |
| 4524 | - return '\n\nCheck the render method of `' + name + '`.'; | |
| 4525 | - } | |
| 4526 | - } | |
| 4027 | +const useSyncExternalStore = use_sync_external_store_shim_index_js__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore; | |
| 4527 | 4028 | |
| 4528 | - return ''; | |
| 4529 | - } | |
| 4530 | -} | |
| 4531 | 4029 | |
| 4532 | -function getSourceInfoErrorAddendum(source) { | |
| 4533 | - { | |
| 4534 | - if (source !== undefined) { | |
| 4535 | - var fileName = source.fileName.replace(/^.*[\\\/]/, ''); | |
| 4536 | - var lineNumber = source.lineNumber; | |
| 4537 | - return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; | |
| 4538 | - } | |
| 4030 | +//# sourceMappingURL=useSyncExternalStore.mjs.map | |
| 4539 | 4031 | |
| 4540 | - return ''; | |
| 4541 | - } | |
| 4542 | -} | |
| 4543 | -/** | |
| 4544 | - * Warn if there's no key explicitly set on dynamic arrays of children or | |
| 4545 | - * object keys are not valid. This allows us to keep track of children between | |
| 4546 | - * updates. | |
| 4547 | - */ | |
| 4548 | 4032 | |
| 4033 | +/***/ }), | |
| 4549 | 4034 | |
| 4550 | -var ownerHasKeyUseWarning = {}; | |
| 4035 | +/***/ "./node_modules/@tanstack/react-query/build/lib/utils.mjs": | |
| 4036 | +/*!****************************************************************!*\ | |
| 4037 | + !*** ./node_modules/@tanstack/react-query/build/lib/utils.mjs ***! | |
| 4038 | + \****************************************************************/ | |
| 4039 | +/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 4551 | 4040 | |
| 4552 | -function getCurrentComponentErrorInfo(parentType) { | |
| 4553 | - { | |
| 4554 | - var info = getDeclarationErrorAddendum(); | |
| 4555 | - | |
| 4556 | - if (!info) { | |
| 4557 | - var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; | |
| 4558 | - | |
| 4559 | - if (parentName) { | |
| 4560 | - info = "\n\nCheck the top-level render call using <" + parentName + ">."; | |
| 4561 | - } | |
| 4562 | - } | |
| 4563 | - | |
| 4564 | - return info; | |
| 4041 | +__webpack_require__.r(__webpack_exports__); | |
| 4042 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 4043 | +/* harmony export */ shouldThrowError: function() { return /* binding */ shouldThrowError; } | |
| 4044 | +/* harmony export */ }); | |
| 4045 | +function shouldThrowError(_useErrorBoundary, params) { | |
| 4046 | + // Allow useErrorBoundary function to override throwing behavior on a per-error basis | |
| 4047 | + if (typeof _useErrorBoundary === 'function') { | |
| 4048 | + return _useErrorBoundary(...params); | |
| 4565 | 4049 | } |
| 4566 | -} | |
| 4567 | -/** | |
| 4568 | - * Warn if the element doesn't have an explicit key assigned to it. | |
| 4569 | - * This element is in an array. The array could grow and shrink or be | |
| 4570 | - * reordered. All children that haven't already been validated are required to | |
| 4571 | - * have a "key" property assigned to it. Error statuses are cached so a warning | |
| 4572 | - * will only be shown once. | |
| 4573 | - * | |
| 4574 | - * @internal | |
| 4575 | - * @param {ReactElement} element Element that requires a key. | |
| 4576 | - * @param {*} parentType element's parent's type. | |
| 4577 | - */ | |
| 4578 | 4050 | |
| 4579 | - | |
| 4580 | -function validateExplicitKey(element, parentType) { | |
| 4581 | - { | |
| 4582 | - if (!element._store || element._store.validated || element.key != null) { | |
| 4583 | - return; | |
| 4584 | - } | |
| 4585 | - | |
| 4586 | - element._store.validated = true; | |
| 4587 | - var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); | |
| 4588 | - | |
| 4589 | - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { | |
| 4590 | - return; | |
| 4591 | - } | |
| 4592 | - | |
| 4593 | - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a | |
| 4594 | - // property, it may be the creator of the child that's responsible for | |
| 4595 | - // assigning it a key. | |
| 4596 | - | |
| 4597 | - var childOwner = ''; | |
| 4598 | - | |
| 4599 | - if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) { | |
| 4600 | - // Give the component that originally created this child. | |
| 4601 | - childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + "."; | |
| 4602 | - } | |
| 4603 | - | |
| 4604 | - setCurrentlyValidatingElement$1(element); | |
| 4605 | - | |
| 4606 | - error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); | |
| 4607 | - | |
| 4608 | - setCurrentlyValidatingElement$1(null); | |
| 4609 | - } | |
| 4051 | + return !!_useErrorBoundary; | |
| 4610 | 4052 | } |
| 4611 | -/** | |
| 4612 | - * Ensure that every element either is passed in a static location, in an | |
| 4613 | - * array with an explicit keys property defined, or in an object literal | |
| 4614 | - * with valid key property. | |
| 4615 | - * | |
| 4616 | - * @internal | |
| 4617 | - * @param {ReactNode} node Statically passed child of any type. | |
| 4618 | - * @param {*} parentType node's parent's type. | |
| 4619 | - */ | |
| 4620 | 4053 | |
| 4621 | 4054 | |
| 4622 | -function validateChildKeys(node, parentType) { | |
| 4623 | - { | |
| 4624 | - if (typeof node !== 'object') { | |
| 4625 | - return; | |
| 4626 | - } | |
| 4055 | +//# sourceMappingURL=utils.mjs.map | |
| 4627 | 4056 | |
| 4628 | - if (isArray(node)) { | |
| 4629 | - for (var i = 0; i < node.length; i++) { | |
| 4630 | - var child = node[i]; | |
| 4631 | 4057 | |
| 4632 | - if (isValidElement(child)) { | |
| 4633 | - validateExplicitKey(child, parentType); | |
| 4634 | - } | |
| 4635 | - } | |
| 4636 | - } else if (isValidElement(node)) { | |
| 4637 | - // This element was passed in a valid location. | |
| 4638 | - if (node._store) { | |
| 4639 | - node._store.validated = true; | |
| 4640 | - } | |
| 4641 | - } else if (node) { | |
| 4642 | - var iteratorFn = getIteratorFn(node); | |
| 4643 | - | |
| 4644 | - if (typeof iteratorFn === 'function') { | |
| 4645 | - // Entry iterators used to provide implicit keys, | |
| 4646 | - // but now we print a separate warning for them later. | |
| 4647 | - if (iteratorFn !== node.entries) { | |
| 4648 | - var iterator = iteratorFn.call(node); | |
| 4649 | - var step; | |
| 4650 | - | |
| 4651 | - while (!(step = iterator.next()).done) { | |
| 4652 | - if (isValidElement(step.value)) { | |
| 4653 | - validateExplicitKey(step.value, parentType); | |
| 4654 | - } | |
| 4655 | - } | |
| 4656 | - } | |
| 4657 | - } | |
| 4658 | - } | |
| 4659 | - } | |
| 4660 | -} | |
| 4661 | -/** | |
| 4662 | - * Given an element, validate that its props follow the propTypes definition, | |
| 4663 | - * provided by the type. | |
| 4664 | - * | |
| 4665 | - * @param {ReactElement} element | |
| 4666 | - */ | |
| 4667 | - | |
| 4668 | - | |
| 4669 | -function validatePropTypes(element) { | |
| 4670 | - { | |
| 4671 | - var type = element.type; | |
| 4672 | - | |
| 4673 | - if (type === null || type === undefined || typeof type === 'string') { | |
| 4674 | - return; | |
| 4675 | - } | |
| 4676 | - | |
| 4677 | - var propTypes; | |
| 4678 | - | |
| 4679 | - if (typeof type === 'function') { | |
| 4680 | - propTypes = type.propTypes; | |
| 4681 | - } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. | |
| 4682 | - // Inner props are checked in the reconciler. | |
| 4683 | - type.$$typeof === REACT_MEMO_TYPE)) { | |
| 4684 | - propTypes = type.propTypes; | |
| 4685 | - } else { | |
| 4686 | - return; | |
| 4687 | - } | |
| 4688 | - | |
| 4689 | - if (propTypes) { | |
| 4690 | - // Intentionally inside to avoid triggering lazy initializers: | |
| 4691 | - var name = getComponentNameFromType(type); | |
| 4692 | - checkPropTypes(propTypes, element.props, 'prop', name, element); | |
| 4693 | - } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { | |
| 4694 | - propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: | |
| 4695 | - | |
| 4696 | - var _name = getComponentNameFromType(type); | |
| 4697 | - | |
| 4698 | - error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); | |
| 4699 | - } | |
| 4700 | - | |
| 4701 | - if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { | |
| 4702 | - error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); | |
| 4703 | - } | |
| 4704 | - } | |
| 4705 | -} | |
| 4706 | -/** | |
| 4707 | - * Given a fragment, validate that it can only be provided with fragment props | |
| 4708 | - * @param {ReactElement} fragment | |
| 4709 | - */ | |
| 4710 | - | |
| 4711 | - | |
| 4712 | -function validateFragmentProps(fragment) { | |
| 4713 | - { | |
| 4714 | - var keys = Object.keys(fragment.props); | |
| 4715 | - | |
| 4716 | - for (var i = 0; i < keys.length; i++) { | |
| 4717 | - var key = keys[i]; | |
| 4718 | - | |
| 4719 | - if (key !== 'children' && key !== 'key') { | |
| 4720 | - setCurrentlyValidatingElement$1(fragment); | |
| 4721 | - | |
| 4722 | - error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); | |
| 4723 | - | |
| 4724 | - setCurrentlyValidatingElement$1(null); | |
| 4725 | - break; | |
| 4726 | - } | |
| 4727 | - } | |
| 4728 | - | |
| 4729 | - if (fragment.ref !== null) { | |
| 4730 | - setCurrentlyValidatingElement$1(fragment); | |
| 4731 | - | |
| 4732 | - error('Invalid attribute `ref` supplied to `React.Fragment`.'); | |
| 4733 | - | |
| 4734 | - setCurrentlyValidatingElement$1(null); | |
| 4735 | - } | |
| 4736 | - } | |
| 4737 | -} | |
| 4738 | - | |
| 4739 | -var didWarnAboutKeySpread = {}; | |
| 4740 | -function jsxWithValidation(type, props, key, isStaticChildren, source, self) { | |
| 4741 | - { | |
| 4742 | - var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to | |
| 4743 | - // succeed and there will likely be errors in render. | |
| 4744 | - | |
| 4745 | - if (!validType) { | |
| 4746 | - var info = ''; | |
| 4747 | - | |
| 4748 | - if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { | |
| 4749 | - info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; | |
| 4750 | - } | |
| 4751 | - | |
| 4752 | - var sourceInfo = getSourceInfoErrorAddendum(source); | |
| 4753 | - | |
| 4754 | - if (sourceInfo) { | |
| 4755 | - info += sourceInfo; | |
| 4756 | - } else { | |
| 4757 | - info += getDeclarationErrorAddendum(); | |
| 4758 | - } | |
| 4759 | - | |
| 4760 | - var typeString; | |
| 4761 | - | |
| 4762 | - if (type === null) { | |
| 4763 | - typeString = 'null'; | |
| 4764 | - } else if (isArray(type)) { | |
| 4765 | - typeString = 'array'; | |
| 4766 | - } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { | |
| 4767 | - typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />"; | |
| 4768 | - info = ' Did you accidentally export a JSX literal instead of a component?'; | |
| 4769 | - } else { | |
| 4770 | - typeString = typeof type; | |
| 4771 | - } | |
| 4772 | - | |
| 4773 | - error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); | |
| 4774 | - } | |
| 4775 | - | |
| 4776 | - var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used. | |
| 4777 | - // TODO: Drop this when these are no longer allowed as the type argument. | |
| 4778 | - | |
| 4779 | - if (element == null) { | |
| 4780 | - return element; | |
| 4781 | - } // Skip key warning if the type isn't valid since our key validation logic | |
| 4782 | - // doesn't expect a non-string/function type and can throw confusing errors. | |
| 4783 | - // We don't want exception behavior to differ between dev and prod. | |
| 4784 | - // (Rendering will throw with a helpful message and as soon as the type is | |
| 4785 | - // fixed, the key warnings will appear.) | |
| 4786 | - | |
| 4787 | - | |
| 4788 | - if (validType) { | |
| 4789 | - var children = props.children; | |
| 4790 | - | |
| 4791 | - if (children !== undefined) { | |
| 4792 | - if (isStaticChildren) { | |
| 4793 | - if (isArray(children)) { | |
| 4794 | - for (var i = 0; i < children.length; i++) { | |
| 4795 | - validateChildKeys(children[i], type); | |
| 4796 | - } | |
| 4797 | - | |
| 4798 | - if (Object.freeze) { | |
| 4799 | - Object.freeze(children); | |
| 4800 | - } | |
| 4801 | - } else { | |
| 4802 | - error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.'); | |
| 4803 | - } | |
| 4804 | - } else { | |
| 4805 | - validateChildKeys(children, type); | |
| 4806 | - } | |
| 4807 | - } | |
| 4808 | - } | |
| 4809 | - | |
| 4810 | - { | |
| 4811 | - if (hasOwnProperty.call(props, 'key')) { | |
| 4812 | - var componentName = getComponentNameFromType(type); | |
| 4813 | - var keys = Object.keys(props).filter(function (k) { | |
| 4814 | - return k !== 'key'; | |
| 4815 | - }); | |
| 4816 | - var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}'; | |
| 4817 | - | |
| 4818 | - if (!didWarnAboutKeySpread[componentName + beforeExample]) { | |
| 4819 | - var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}'; | |
| 4820 | - | |
| 4821 | - error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName); | |
| 4822 | - | |
| 4823 | - didWarnAboutKeySpread[componentName + beforeExample] = true; | |
| 4824 | - } | |
| 4825 | - } | |
| 4826 | - } | |
| 4827 | - | |
| 4828 | - if (type === REACT_FRAGMENT_TYPE) { | |
| 4829 | - validateFragmentProps(element); | |
| 4830 | - } else { | |
| 4831 | - validatePropTypes(element); | |
| 4832 | - } | |
| 4833 | - | |
| 4834 | - return element; | |
| 4835 | - } | |
| 4836 | -} // These two functions exist to still get child warnings in dev | |
| 4837 | -// even with the prod transform. This means that jsxDEV is purely | |
| 4838 | -// opt-in behavior for better messages but that we won't stop | |
| 4839 | -// giving you warnings if you use production apis. | |
| 4840 | - | |
| 4841 | -function jsxWithValidationStatic(type, props, key) { | |
| 4842 | - { | |
| 4843 | - return jsxWithValidation(type, props, key, true); | |
| 4844 | - } | |
| 4845 | -} | |
| 4846 | -function jsxWithValidationDynamic(type, props, key) { | |
| 4847 | - { | |
| 4848 | - return jsxWithValidation(type, props, key, false); | |
| 4849 | - } | |
| 4850 | -} | |
| 4851 | - | |
| 4852 | -var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children. | |
| 4853 | -// for now we can ship identical prod functions | |
| 4854 | - | |
| 4855 | -var jsxs = jsxWithValidationStatic ; | |
| 4856 | - | |
| 4857 | -exports.Fragment = REACT_FRAGMENT_TYPE; | |
| 4858 | -exports.jsx = jsx; | |
| 4859 | -exports.jsxs = jsxs; | |
| 4860 | - })(); | |
| 4861 | -} | |
| 4862 | - | |
| 4863 | - | |
| 4864 | -/***/ }), | |
| 4865 | - | |
| 4866 | -/***/ "./node_modules/react/jsx-runtime.js": | |
| 4867 | -/*!*******************************************!*\ | |
| 4868 | - !*** ./node_modules/react/jsx-runtime.js ***! | |
| 4869 | - \*******************************************/ | |
| 4870 | -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { | |
| 4871 | - | |
| 4872 | - | |
| 4873 | - | |
| 4874 | -if (false) // removed by dead control flow | |
| 4875 | -{} else { | |
| 4876 | - module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ "./node_modules/react/cjs/react-jsx-runtime.development.js"); | |
| 4877 | -} | |
| 4878 | - | |
| 4879 | - | |
| 4880 | -/***/ }), | |
| 4881 | - | |
| 4882 | -/***/ "react": | |
| 4883 | -/*!**************************!*\ | |
| 4884 | - !*** external ["React"] ***! | |
| 4885 | - \**************************/ | |
| 4886 | -/***/ (function(module) { | |
| 4887 | - | |
| 4888 | -module.exports = window["React"]; | |
| 4889 | - | |
| 4890 | 4058 | /***/ }) |
| 4891 | 4059 | |
| 4892 | 4060 | /******/ }); |
| 4893 | 4061 | /************************************************************************/ |
| @@ -4945,45 +4113,31 @@ | ||
| 4945 | 4113 | /******/ }(); |
| 4946 | 4114 | /******/ |
| 4947 | 4115 | /************************************************************************/ |
| 4948 | 4116 | var __webpack_exports__ = {}; |
| 4949 | -// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. | |
| 4117 | +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | |
| 4950 | 4118 | !function() { |
| 4951 | -/*!***************************************************!*\ | |
| 4952 | - !*** ./packages/packages/libs/query/src/index.ts ***! | |
| 4953 | - \***************************************************/ | |
| 4119 | +/*!******************************************************!*\ | |
| 4120 | + !*** ./node_modules/@elementor/query/dist/index.mjs ***! | |
| 4121 | + \******************************************************/ | |
| 4954 | 4122 | __webpack_require__.r(__webpack_exports__); |
| 4955 | 4123 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4956 | 4124 | /* harmony export */ QueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient; }, |
| 4957 | -/* harmony export */ QueryClientProvider: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__.QueryClientProvider; }, | |
| 4125 | +/* harmony export */ QueryClientProvider: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__.QueryClientProvider; }, | |
| 4958 | 4126 | /* harmony export */ createQueryClient: function() { return /* binding */ createQueryClient; }, |
| 4959 | -/* harmony export */ getQueryClient: function() { return /* binding */ getQueryClient; }, | |
| 4960 | -/* harmony export */ useInfiniteQuery: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.useInfiniteQuery; }, | |
| 4961 | -/* harmony export */ useIsMutating: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__.useIsMutating; }, | |
| 4962 | -/* harmony export */ useMutation: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_4__.useMutation; }, | |
| 4963 | -/* harmony export */ useQuery: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__.useQuery; }, | |
| 4964 | -/* harmony export */ useQueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__.useQueryClient; } | |
| 4127 | +/* harmony export */ useMutation: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__.useMutation; }, | |
| 4128 | +/* harmony export */ useQuery: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__.useQuery; }, | |
| 4129 | +/* harmony export */ useQueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__.useQueryClient; } | |
| 4965 | 4130 | /* harmony export */ }); |
| 4966 | -/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/query-core/build/modern/queryClient.js"); | |
| 4967 | -/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useQuery.js"); | |
| 4968 | -/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); | |
| 4969 | -/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useMutationState.js"); | |
| 4970 | -/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useMutation.js"); | |
| 4971 | -/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js"); | |
| 4131 | +/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/query-core/build/lib/queryClient.mjs"); | |
| 4132 | +/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs"); | |
| 4133 | +/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/lib/useMutation.mjs"); | |
| 4134 | +/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/lib/useQuery.mjs"); | |
| 4135 | +// src/index.ts | |
| 4972 | 4136 | |
| 4973 | 4137 | |
| 4974 | -let queryClient; | |
| 4975 | -function getQueryClient() { | |
| 4976 | - if (!queryClient) { | |
| 4977 | - throw new Error('Query client is not created yet.'); | |
| 4978 | - } | |
| 4979 | - return queryClient; | |
| 4980 | -} | |
| 4981 | 4138 | function createQueryClient() { |
| 4982 | - if (queryClient) { | |
| 4983 | - throw new Error('Query client is already created.'); | |
| 4984 | - } | |
| 4985 | - queryClient = new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient({ | |
| 4139 | + return new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient({ | |
| 4986 | 4140 | defaultOptions: { |
| 4987 | 4141 | queries: { |
| 4988 | 4142 | refetchOnWindowFocus: false, |
| 4989 | 4143 | refetchOnReconnect: false |
| @@ -4989,12 +4143,11 @@ | ||
| 4989 | 4143 | refetchOnReconnect: false |
| 4990 | 4144 | } |
| 4991 | 4145 | } |
| 4992 | 4146 | }); |
| 4993 | - return queryClient; | |
| 4994 | 4147 | } |
| 4148 | + | |
| 4149 | +//# sourceMappingURL=index.mjs.map | |
| 4995 | 4150 | }(); |
| 4996 | 4151 | (window.elementorV2 = window.elementorV2 || {}).query = __webpack_exports__; |
| 4997 | 4152 | /******/ })() |
| 4998 | -; | |
| 4999 | -window.elementorV2.query?.init?.(); | |
| 5000 | -//# sourceMappingURL=query.js.map | |
| 4153 | +; | |