| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ var __webpack_modules__ = ({ |
| 4 |
|
| 5 |
/***/ "react": |
| 6 |
/*!**************************!*\ |
| 7 |
!*** external ["React"] ***! |
| 8 |
\**************************/ |
| 9 |
/***/ (function(module) { |
| 10 |
|
| 11 |
module.exports = window["React"]; |
| 12 |
|
| 13 |
/***/ }), |
| 14 |
|
| 15 |
/***/ "./node_modules/@tanstack/query-core/build/modern/focusManager.js": |
| 16 |
/*!************************************************************************!*\ |
| 17 |
!*** ./node_modules/@tanstack/query-core/build/modern/focusManager.js ***! |
| 18 |
\************************************************************************/ |
| 19 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 20 |
|
| 21 |
__webpack_require__.r(__webpack_exports__); |
| 22 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 23 |
/* harmony export */ FocusManager: function() { return /* binding */ FocusManager; }, |
| 24 |
/* harmony export */ focusManager: function() { return /* binding */ focusManager; } |
| 25 |
/* harmony export */ }); |
| 26 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 27 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 28 |
// src/focusManager.ts |
| 29 |
|
| 30 |
|
| 31 |
var FocusManager = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 32 |
#focused; |
| 33 |
#cleanup; |
| 34 |
#setup; |
| 35 |
constructor() { |
| 36 |
super(); |
| 37 |
this.#setup = (onFocus) => { |
| 38 |
if (!_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { |
| 39 |
const listener = () => onFocus(); |
| 40 |
window.addEventListener("visibilitychange", listener, false); |
| 41 |
return () => { |
| 42 |
window.removeEventListener("visibilitychange", listener); |
| 43 |
}; |
| 44 |
} |
| 45 |
return; |
| 46 |
}; |
| 47 |
} |
| 48 |
onSubscribe() { |
| 49 |
if (!this.#cleanup) { |
| 50 |
this.setEventListener(this.#setup); |
| 51 |
} |
| 52 |
} |
| 53 |
onUnsubscribe() { |
| 54 |
if (!this.hasListeners()) { |
| 55 |
this.#cleanup?.(); |
| 56 |
this.#cleanup = void 0; |
| 57 |
} |
| 58 |
} |
| 59 |
setEventListener(setup) { |
| 60 |
this.#setup = setup; |
| 61 |
this.#cleanup?.(); |
| 62 |
this.#cleanup = setup((focused) => { |
| 63 |
if (typeof focused === "boolean") { |
| 64 |
this.setFocused(focused); |
| 65 |
} else { |
| 66 |
this.onFocus(); |
| 67 |
} |
| 68 |
}); |
| 69 |
} |
| 70 |
setFocused(focused) { |
| 71 |
const changed = this.#focused !== focused; |
| 72 |
if (changed) { |
| 73 |
this.#focused = focused; |
| 74 |
this.onFocus(); |
| 75 |
} |
| 76 |
} |
| 77 |
onFocus() { |
| 78 |
this.listeners.forEach((listener) => { |
| 79 |
listener(); |
| 80 |
}); |
| 81 |
} |
| 82 |
isFocused() { |
| 83 |
if (typeof this.#focused === "boolean") { |
| 84 |
return this.#focused; |
| 85 |
} |
| 86 |
return globalThis.document?.visibilityState !== "hidden"; |
| 87 |
} |
| 88 |
}; |
| 89 |
var focusManager = new FocusManager(); |
| 90 |
|
| 91 |
//# sourceMappingURL=focusManager.js.map |
| 92 |
|
| 93 |
/***/ }), |
| 94 |
|
| 95 |
/***/ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js": |
| 96 |
/*!*********************************************************************************!*\ |
| 97 |
!*** ./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js ***! |
| 98 |
\*********************************************************************************/ |
| 99 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 100 |
|
| 101 |
__webpack_require__.r(__webpack_exports__); |
| 102 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 103 |
/* harmony export */ hasNextPage: function() { return /* binding */ hasNextPage; }, |
| 104 |
/* harmony export */ hasPreviousPage: function() { return /* binding */ hasPreviousPage; }, |
| 105 |
/* harmony export */ infiniteQueryBehavior: function() { return /* binding */ infiniteQueryBehavior; } |
| 106 |
/* harmony export */ }); |
| 107 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 108 |
// src/infiniteQueryBehavior.ts |
| 109 |
|
| 110 |
function infiniteQueryBehavior(pages) { |
| 111 |
return { |
| 112 |
onFetch: (context, query) => { |
| 113 |
const fetchFn = async () => { |
| 114 |
const options = context.options; |
| 115 |
const direction = context.fetchOptions?.meta?.fetchMore?.direction; |
| 116 |
const oldPages = context.state.data?.pages || []; |
| 117 |
const oldPageParams = context.state.data?.pageParams || []; |
| 118 |
const empty = { pages: [], pageParams: [] }; |
| 119 |
let cancelled = false; |
| 120 |
const addSignalProperty = (object) => { |
| 121 |
Object.defineProperty(object, "signal", { |
| 122 |
enumerable: true, |
| 123 |
get: () => { |
| 124 |
if (context.signal.aborted) { |
| 125 |
cancelled = true; |
| 126 |
} else { |
| 127 |
context.signal.addEventListener("abort", () => { |
| 128 |
cancelled = true; |
| 129 |
}); |
| 130 |
} |
| 131 |
return context.signal; |
| 132 |
} |
| 133 |
}); |
| 134 |
}; |
| 135 |
const queryFn = context.options.queryFn || (() => Promise.reject( |
| 136 |
new Error(`Missing queryFn: '${context.options.queryHash}'`) |
| 137 |
)); |
| 138 |
const fetchPage = async (data, param, previous) => { |
| 139 |
if (cancelled) { |
| 140 |
return Promise.reject(); |
| 141 |
} |
| 142 |
if (param == null && data.pages.length) { |
| 143 |
return Promise.resolve(data); |
| 144 |
} |
| 145 |
const queryFnContext = { |
| 146 |
queryKey: context.queryKey, |
| 147 |
pageParam: param, |
| 148 |
direction: previous ? "backward" : "forward", |
| 149 |
meta: context.options.meta |
| 150 |
}; |
| 151 |
addSignalProperty(queryFnContext); |
| 152 |
const page = await queryFn( |
| 153 |
queryFnContext |
| 154 |
); |
| 155 |
const { maxPages } = context.options; |
| 156 |
const addTo = previous ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.addToStart : _utils_js__WEBPACK_IMPORTED_MODULE_0__.addToEnd; |
| 157 |
return { |
| 158 |
pages: addTo(data.pages, page, maxPages), |
| 159 |
pageParams: addTo(data.pageParams, param, maxPages) |
| 160 |
}; |
| 161 |
}; |
| 162 |
let result; |
| 163 |
if (direction && oldPages.length) { |
| 164 |
const previous = direction === "backward"; |
| 165 |
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam; |
| 166 |
const oldData = { |
| 167 |
pages: oldPages, |
| 168 |
pageParams: oldPageParams |
| 169 |
}; |
| 170 |
const param = pageParamFn(options, oldData); |
| 171 |
result = await fetchPage(oldData, param, previous); |
| 172 |
} else { |
| 173 |
result = await fetchPage( |
| 174 |
empty, |
| 175 |
oldPageParams[0] ?? options.initialPageParam |
| 176 |
); |
| 177 |
const remainingPages = pages ?? oldPages.length; |
| 178 |
for (let i = 1; i < remainingPages; i++) { |
| 179 |
const param = getNextPageParam(options, result); |
| 180 |
result = await fetchPage(result, param); |
| 181 |
} |
| 182 |
} |
| 183 |
return result; |
| 184 |
}; |
| 185 |
if (context.options.persister) { |
| 186 |
context.fetchFn = () => { |
| 187 |
return context.options.persister?.( |
| 188 |
fetchFn, |
| 189 |
{ |
| 190 |
queryKey: context.queryKey, |
| 191 |
meta: context.options.meta, |
| 192 |
signal: context.signal |
| 193 |
}, |
| 194 |
query |
| 195 |
); |
| 196 |
}; |
| 197 |
} else { |
| 198 |
context.fetchFn = fetchFn; |
| 199 |
} |
| 200 |
} |
| 201 |
}; |
| 202 |
} |
| 203 |
function getNextPageParam(options, { pages, pageParams }) { |
| 204 |
const lastIndex = pages.length - 1; |
| 205 |
return options.getNextPageParam( |
| 206 |
pages[lastIndex], |
| 207 |
pages, |
| 208 |
pageParams[lastIndex], |
| 209 |
pageParams |
| 210 |
); |
| 211 |
} |
| 212 |
function getPreviousPageParam(options, { pages, pageParams }) { |
| 213 |
return options.getPreviousPageParam?.( |
| 214 |
pages[0], |
| 215 |
pages, |
| 216 |
pageParams[0], |
| 217 |
pageParams |
| 218 |
); |
| 219 |
} |
| 220 |
function hasNextPage(options, data) { |
| 221 |
if (!data) |
| 222 |
return false; |
| 223 |
return getNextPageParam(options, data) != null; |
| 224 |
} |
| 225 |
function hasPreviousPage(options, data) { |
| 226 |
if (!data || !options.getPreviousPageParam) |
| 227 |
return false; |
| 228 |
return getPreviousPageParam(options, data) != null; |
| 229 |
} |
| 230 |
|
| 231 |
//# sourceMappingURL=infiniteQueryBehavior.js.map |
| 232 |
|
| 233 |
/***/ }), |
| 234 |
|
| 235 |
/***/ "./node_modules/@tanstack/query-core/build/modern/mutation.js": |
| 236 |
/*!********************************************************************!*\ |
| 237 |
!*** ./node_modules/@tanstack/query-core/build/modern/mutation.js ***! |
| 238 |
\********************************************************************/ |
| 239 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 240 |
|
| 241 |
__webpack_require__.r(__webpack_exports__); |
| 242 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 243 |
/* harmony export */ Mutation: function() { return /* binding */ Mutation; }, |
| 244 |
/* harmony export */ getDefaultState: function() { return /* binding */ getDefaultState; } |
| 245 |
/* harmony export */ }); |
| 246 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 247 |
/* harmony import */ var _removable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./removable.js */ "./node_modules/@tanstack/query-core/build/modern/removable.js"); |
| 248 |
/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); |
| 249 |
// src/mutation.ts |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
var Mutation = class extends _removable_js__WEBPACK_IMPORTED_MODULE_0__.Removable { |
| 254 |
constructor(config) { |
| 255 |
super(); |
| 256 |
this.mutationId = config.mutationId; |
| 257 |
this.#defaultOptions = config.defaultOptions; |
| 258 |
this.#mutationCache = config.mutationCache; |
| 259 |
this.#observers = []; |
| 260 |
this.state = config.state || getDefaultState(); |
| 261 |
this.setOptions(config.options); |
| 262 |
this.scheduleGc(); |
| 263 |
} |
| 264 |
#observers; |
| 265 |
#defaultOptions; |
| 266 |
#mutationCache; |
| 267 |
#retryer; |
| 268 |
setOptions(options) { |
| 269 |
this.options = { ...this.#defaultOptions, ...options }; |
| 270 |
this.updateGcTime(this.options.gcTime); |
| 271 |
} |
| 272 |
get meta() { |
| 273 |
return this.options.meta; |
| 274 |
} |
| 275 |
addObserver(observer) { |
| 276 |
if (!this.#observers.includes(observer)) { |
| 277 |
this.#observers.push(observer); |
| 278 |
this.clearGcTimeout(); |
| 279 |
this.#mutationCache.notify({ |
| 280 |
type: "observerAdded", |
| 281 |
mutation: this, |
| 282 |
observer |
| 283 |
}); |
| 284 |
} |
| 285 |
} |
| 286 |
removeObserver(observer) { |
| 287 |
this.#observers = this.#observers.filter((x) => x !== observer); |
| 288 |
this.scheduleGc(); |
| 289 |
this.#mutationCache.notify({ |
| 290 |
type: "observerRemoved", |
| 291 |
mutation: this, |
| 292 |
observer |
| 293 |
}); |
| 294 |
} |
| 295 |
optionalRemove() { |
| 296 |
if (!this.#observers.length) { |
| 297 |
if (this.state.status === "pending") { |
| 298 |
this.scheduleGc(); |
| 299 |
} else { |
| 300 |
this.#mutationCache.remove(this); |
| 301 |
} |
| 302 |
} |
| 303 |
} |
| 304 |
continue() { |
| 305 |
return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before |
| 306 |
this.execute(this.state.variables); |
| 307 |
} |
| 308 |
async execute(variables) { |
| 309 |
const executeMutation = () => { |
| 310 |
this.#retryer = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_1__.createRetryer)({ |
| 311 |
fn: () => { |
| 312 |
if (!this.options.mutationFn) { |
| 313 |
return Promise.reject(new Error("No mutationFn found")); |
| 314 |
} |
| 315 |
return this.options.mutationFn(variables); |
| 316 |
}, |
| 317 |
onFail: (failureCount, error) => { |
| 318 |
this.#dispatch({ type: "failed", failureCount, error }); |
| 319 |
}, |
| 320 |
onPause: () => { |
| 321 |
this.#dispatch({ type: "pause" }); |
| 322 |
}, |
| 323 |
onContinue: () => { |
| 324 |
this.#dispatch({ type: "continue" }); |
| 325 |
}, |
| 326 |
retry: this.options.retry ?? 0, |
| 327 |
retryDelay: this.options.retryDelay, |
| 328 |
networkMode: this.options.networkMode |
| 329 |
}); |
| 330 |
return this.#retryer.promise; |
| 331 |
}; |
| 332 |
const restored = this.state.status === "pending"; |
| 333 |
try { |
| 334 |
if (!restored) { |
| 335 |
this.#dispatch({ type: "pending", variables }); |
| 336 |
await this.#mutationCache.config.onMutate?.( |
| 337 |
variables, |
| 338 |
this |
| 339 |
); |
| 340 |
const context = await this.options.onMutate?.(variables); |
| 341 |
if (context !== this.state.context) { |
| 342 |
this.#dispatch({ |
| 343 |
type: "pending", |
| 344 |
context, |
| 345 |
variables |
| 346 |
}); |
| 347 |
} |
| 348 |
} |
| 349 |
const data = await executeMutation(); |
| 350 |
await this.#mutationCache.config.onSuccess?.( |
| 351 |
data, |
| 352 |
variables, |
| 353 |
this.state.context, |
| 354 |
this |
| 355 |
); |
| 356 |
await this.options.onSuccess?.(data, variables, this.state.context); |
| 357 |
await this.#mutationCache.config.onSettled?.( |
| 358 |
data, |
| 359 |
null, |
| 360 |
this.state.variables, |
| 361 |
this.state.context, |
| 362 |
this |
| 363 |
); |
| 364 |
await this.options.onSettled?.(data, null, variables, this.state.context); |
| 365 |
this.#dispatch({ type: "success", data }); |
| 366 |
return data; |
| 367 |
} catch (error) { |
| 368 |
try { |
| 369 |
await this.#mutationCache.config.onError?.( |
| 370 |
error, |
| 371 |
variables, |
| 372 |
this.state.context, |
| 373 |
this |
| 374 |
); |
| 375 |
await this.options.onError?.( |
| 376 |
error, |
| 377 |
variables, |
| 378 |
this.state.context |
| 379 |
); |
| 380 |
await this.#mutationCache.config.onSettled?.( |
| 381 |
void 0, |
| 382 |
error, |
| 383 |
this.state.variables, |
| 384 |
this.state.context, |
| 385 |
this |
| 386 |
); |
| 387 |
await this.options.onSettled?.( |
| 388 |
void 0, |
| 389 |
error, |
| 390 |
variables, |
| 391 |
this.state.context |
| 392 |
); |
| 393 |
throw error; |
| 394 |
} finally { |
| 395 |
this.#dispatch({ type: "error", error }); |
| 396 |
} |
| 397 |
} |
| 398 |
} |
| 399 |
#dispatch(action) { |
| 400 |
const reducer = (state) => { |
| 401 |
switch (action.type) { |
| 402 |
case "failed": |
| 403 |
return { |
| 404 |
...state, |
| 405 |
failureCount: action.failureCount, |
| 406 |
failureReason: action.error |
| 407 |
}; |
| 408 |
case "pause": |
| 409 |
return { |
| 410 |
...state, |
| 411 |
isPaused: true |
| 412 |
}; |
| 413 |
case "continue": |
| 414 |
return { |
| 415 |
...state, |
| 416 |
isPaused: false |
| 417 |
}; |
| 418 |
case "pending": |
| 419 |
return { |
| 420 |
...state, |
| 421 |
context: action.context, |
| 422 |
data: void 0, |
| 423 |
failureCount: 0, |
| 424 |
failureReason: null, |
| 425 |
error: null, |
| 426 |
isPaused: !(0,_retryer_js__WEBPACK_IMPORTED_MODULE_1__.canFetch)(this.options.networkMode), |
| 427 |
status: "pending", |
| 428 |
variables: action.variables, |
| 429 |
submittedAt: Date.now() |
| 430 |
}; |
| 431 |
case "success": |
| 432 |
return { |
| 433 |
...state, |
| 434 |
data: action.data, |
| 435 |
failureCount: 0, |
| 436 |
failureReason: null, |
| 437 |
error: null, |
| 438 |
status: "success", |
| 439 |
isPaused: false |
| 440 |
}; |
| 441 |
case "error": |
| 442 |
return { |
| 443 |
...state, |
| 444 |
data: void 0, |
| 445 |
error: action.error, |
| 446 |
failureCount: state.failureCount + 1, |
| 447 |
failureReason: action.error, |
| 448 |
isPaused: false, |
| 449 |
status: "error" |
| 450 |
}; |
| 451 |
} |
| 452 |
}; |
| 453 |
this.state = reducer(this.state); |
| 454 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 455 |
this.#observers.forEach((observer) => { |
| 456 |
observer.onMutationUpdate(action); |
| 457 |
}); |
| 458 |
this.#mutationCache.notify({ |
| 459 |
mutation: this, |
| 460 |
type: "updated", |
| 461 |
action |
| 462 |
}); |
| 463 |
}); |
| 464 |
} |
| 465 |
}; |
| 466 |
function getDefaultState() { |
| 467 |
return { |
| 468 |
context: void 0, |
| 469 |
data: void 0, |
| 470 |
error: null, |
| 471 |
failureCount: 0, |
| 472 |
failureReason: null, |
| 473 |
isPaused: false, |
| 474 |
status: "idle", |
| 475 |
variables: void 0, |
| 476 |
submittedAt: 0 |
| 477 |
}; |
| 478 |
} |
| 479 |
|
| 480 |
//# sourceMappingURL=mutation.js.map |
| 481 |
|
| 482 |
/***/ }), |
| 483 |
|
| 484 |
/***/ "./node_modules/@tanstack/query-core/build/modern/mutationCache.js": |
| 485 |
/*!*************************************************************************!*\ |
| 486 |
!*** ./node_modules/@tanstack/query-core/build/modern/mutationCache.js ***! |
| 487 |
\*************************************************************************/ |
| 488 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 489 |
|
| 490 |
__webpack_require__.r(__webpack_exports__); |
| 491 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 492 |
/* harmony export */ MutationCache: function() { return /* binding */ MutationCache; } |
| 493 |
/* harmony export */ }); |
| 494 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 495 |
/* harmony import */ var _mutation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutation.js */ "./node_modules/@tanstack/query-core/build/modern/mutation.js"); |
| 496 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 497 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 498 |
// src/mutationCache.ts |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
var MutationCache = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 504 |
constructor(config = {}) { |
| 505 |
super(); |
| 506 |
this.config = config; |
| 507 |
this.#mutations = []; |
| 508 |
this.#mutationId = 0; |
| 509 |
} |
| 510 |
#mutations; |
| 511 |
#mutationId; |
| 512 |
#resuming; |
| 513 |
build(client, options, state) { |
| 514 |
const mutation = new _mutation_js__WEBPACK_IMPORTED_MODULE_1__.Mutation({ |
| 515 |
mutationCache: this, |
| 516 |
mutationId: ++this.#mutationId, |
| 517 |
options: client.defaultMutationOptions(options), |
| 518 |
state |
| 519 |
}); |
| 520 |
this.add(mutation); |
| 521 |
return mutation; |
| 522 |
} |
| 523 |
add(mutation) { |
| 524 |
this.#mutations.push(mutation); |
| 525 |
this.notify({ type: "added", mutation }); |
| 526 |
} |
| 527 |
remove(mutation) { |
| 528 |
this.#mutations = this.#mutations.filter((x) => x !== mutation); |
| 529 |
this.notify({ type: "removed", mutation }); |
| 530 |
} |
| 531 |
clear() { |
| 532 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 533 |
this.#mutations.forEach((mutation) => { |
| 534 |
this.remove(mutation); |
| 535 |
}); |
| 536 |
}); |
| 537 |
} |
| 538 |
getAll() { |
| 539 |
return this.#mutations; |
| 540 |
} |
| 541 |
find(filters) { |
| 542 |
const defaultedFilters = { exact: true, ...filters }; |
| 543 |
return this.#mutations.find( |
| 544 |
(mutation) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.matchMutation)(defaultedFilters, mutation) |
| 545 |
); |
| 546 |
} |
| 547 |
findAll(filters = {}) { |
| 548 |
return this.#mutations.filter( |
| 549 |
(mutation) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.matchMutation)(filters, mutation) |
| 550 |
); |
| 551 |
} |
| 552 |
notify(event) { |
| 553 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 554 |
this.listeners.forEach((listener) => { |
| 555 |
listener(event); |
| 556 |
}); |
| 557 |
}); |
| 558 |
} |
| 559 |
resumePausedMutations() { |
| 560 |
this.#resuming = (this.#resuming ?? Promise.resolve()).then(() => { |
| 561 |
const pausedMutations = this.#mutations.filter((x) => x.state.isPaused); |
| 562 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch( |
| 563 |
() => pausedMutations.reduce( |
| 564 |
(promise, mutation) => promise.then(() => mutation.continue().catch(_utils_js__WEBPACK_IMPORTED_MODULE_3__.noop)), |
| 565 |
Promise.resolve() |
| 566 |
) |
| 567 |
); |
| 568 |
}).then(() => { |
| 569 |
this.#resuming = void 0; |
| 570 |
}); |
| 571 |
return this.#resuming; |
| 572 |
} |
| 573 |
}; |
| 574 |
|
| 575 |
//# sourceMappingURL=mutationCache.js.map |
| 576 |
|
| 577 |
/***/ }), |
| 578 |
|
| 579 |
/***/ "./node_modules/@tanstack/query-core/build/modern/mutationObserver.js": |
| 580 |
/*!****************************************************************************!*\ |
| 581 |
!*** ./node_modules/@tanstack/query-core/build/modern/mutationObserver.js ***! |
| 582 |
\****************************************************************************/ |
| 583 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 584 |
|
| 585 |
__webpack_require__.r(__webpack_exports__); |
| 586 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 587 |
/* harmony export */ MutationObserver: function() { return /* binding */ MutationObserver; } |
| 588 |
/* harmony export */ }); |
| 589 |
/* harmony import */ var _mutation_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mutation.js */ "./node_modules/@tanstack/query-core/build/modern/mutation.js"); |
| 590 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 591 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 592 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 593 |
// src/mutationObserver.ts |
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
var MutationObserver = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 599 |
constructor(client, options) { |
| 600 |
super(); |
| 601 |
this.#currentResult = void 0; |
| 602 |
this.#client = client; |
| 603 |
this.setOptions(options); |
| 604 |
this.bindMethods(); |
| 605 |
this.#updateResult(); |
| 606 |
} |
| 607 |
#client; |
| 608 |
#currentResult; |
| 609 |
#currentMutation; |
| 610 |
#mutateOptions; |
| 611 |
bindMethods() { |
| 612 |
this.mutate = this.mutate.bind(this); |
| 613 |
this.reset = this.reset.bind(this); |
| 614 |
} |
| 615 |
setOptions(options) { |
| 616 |
const prevOptions = this.options; |
| 617 |
this.options = this.#client.defaultMutationOptions(options); |
| 618 |
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(prevOptions, this.options)) { |
| 619 |
this.#client.getMutationCache().notify({ |
| 620 |
type: "observerOptionsUpdated", |
| 621 |
mutation: this.#currentMutation, |
| 622 |
observer: this |
| 623 |
}); |
| 624 |
} |
| 625 |
this.#currentMutation?.setOptions(this.options); |
| 626 |
} |
| 627 |
onUnsubscribe() { |
| 628 |
if (!this.hasListeners()) { |
| 629 |
this.#currentMutation?.removeObserver(this); |
| 630 |
} |
| 631 |
} |
| 632 |
onMutationUpdate(action) { |
| 633 |
this.#updateResult(); |
| 634 |
this.#notify(action); |
| 635 |
} |
| 636 |
getCurrentResult() { |
| 637 |
return this.#currentResult; |
| 638 |
} |
| 639 |
reset() { |
| 640 |
this.#currentMutation = void 0; |
| 641 |
this.#updateResult(); |
| 642 |
this.#notify(); |
| 643 |
} |
| 644 |
mutate(variables, options) { |
| 645 |
this.#mutateOptions = options; |
| 646 |
this.#currentMutation?.removeObserver(this); |
| 647 |
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options); |
| 648 |
this.#currentMutation.addObserver(this); |
| 649 |
return this.#currentMutation.execute(variables); |
| 650 |
} |
| 651 |
#updateResult() { |
| 652 |
const state = this.#currentMutation?.state ?? (0,_mutation_js__WEBPACK_IMPORTED_MODULE_2__.getDefaultState)(); |
| 653 |
this.#currentResult = { |
| 654 |
...state, |
| 655 |
isPending: state.status === "pending", |
| 656 |
isSuccess: state.status === "success", |
| 657 |
isError: state.status === "error", |
| 658 |
isIdle: state.status === "idle", |
| 659 |
mutate: this.mutate, |
| 660 |
reset: this.reset |
| 661 |
}; |
| 662 |
} |
| 663 |
#notify(action) { |
| 664 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { |
| 665 |
if (this.#mutateOptions && this.hasListeners()) { |
| 666 |
if (action?.type === "success") { |
| 667 |
this.#mutateOptions.onSuccess?.( |
| 668 |
action.data, |
| 669 |
this.#currentResult.variables, |
| 670 |
this.#currentResult.context |
| 671 |
); |
| 672 |
this.#mutateOptions.onSettled?.( |
| 673 |
action.data, |
| 674 |
null, |
| 675 |
this.#currentResult.variables, |
| 676 |
this.#currentResult.context |
| 677 |
); |
| 678 |
} else if (action?.type === "error") { |
| 679 |
this.#mutateOptions.onError?.( |
| 680 |
action.error, |
| 681 |
this.#currentResult.variables, |
| 682 |
this.#currentResult.context |
| 683 |
); |
| 684 |
this.#mutateOptions.onSettled?.( |
| 685 |
void 0, |
| 686 |
action.error, |
| 687 |
this.#currentResult.variables, |
| 688 |
this.#currentResult.context |
| 689 |
); |
| 690 |
} |
| 691 |
} |
| 692 |
this.listeners.forEach((listener) => { |
| 693 |
listener(this.#currentResult); |
| 694 |
}); |
| 695 |
}); |
| 696 |
} |
| 697 |
}; |
| 698 |
|
| 699 |
//# sourceMappingURL=mutationObserver.js.map |
| 700 |
|
| 701 |
/***/ }), |
| 702 |
|
| 703 |
/***/ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js": |
| 704 |
/*!*************************************************************************!*\ |
| 705 |
!*** ./node_modules/@tanstack/query-core/build/modern/notifyManager.js ***! |
| 706 |
\*************************************************************************/ |
| 707 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 708 |
|
| 709 |
__webpack_require__.r(__webpack_exports__); |
| 710 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 711 |
/* harmony export */ createNotifyManager: function() { return /* binding */ createNotifyManager; }, |
| 712 |
/* harmony export */ notifyManager: function() { return /* binding */ notifyManager; } |
| 713 |
/* harmony export */ }); |
| 714 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 715 |
// src/notifyManager.ts |
| 716 |
|
| 717 |
function createNotifyManager() { |
| 718 |
let queue = []; |
| 719 |
let transactions = 0; |
| 720 |
let notifyFn = (callback) => { |
| 721 |
callback(); |
| 722 |
}; |
| 723 |
let batchNotifyFn = (callback) => { |
| 724 |
callback(); |
| 725 |
}; |
| 726 |
const batch = (callback) => { |
| 727 |
let result; |
| 728 |
transactions++; |
| 729 |
try { |
| 730 |
result = callback(); |
| 731 |
} finally { |
| 732 |
transactions--; |
| 733 |
if (!transactions) { |
| 734 |
flush(); |
| 735 |
} |
| 736 |
} |
| 737 |
return result; |
| 738 |
}; |
| 739 |
const schedule = (callback) => { |
| 740 |
if (transactions) { |
| 741 |
queue.push(callback); |
| 742 |
} else { |
| 743 |
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scheduleMicrotask)(() => { |
| 744 |
notifyFn(callback); |
| 745 |
}); |
| 746 |
} |
| 747 |
}; |
| 748 |
const batchCalls = (callback) => { |
| 749 |
return (...args) => { |
| 750 |
schedule(() => { |
| 751 |
callback(...args); |
| 752 |
}); |
| 753 |
}; |
| 754 |
}; |
| 755 |
const flush = () => { |
| 756 |
const originalQueue = queue; |
| 757 |
queue = []; |
| 758 |
if (originalQueue.length) { |
| 759 |
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scheduleMicrotask)(() => { |
| 760 |
batchNotifyFn(() => { |
| 761 |
originalQueue.forEach((callback) => { |
| 762 |
notifyFn(callback); |
| 763 |
}); |
| 764 |
}); |
| 765 |
}); |
| 766 |
} |
| 767 |
}; |
| 768 |
const setNotifyFunction = (fn) => { |
| 769 |
notifyFn = fn; |
| 770 |
}; |
| 771 |
const setBatchNotifyFunction = (fn) => { |
| 772 |
batchNotifyFn = fn; |
| 773 |
}; |
| 774 |
return { |
| 775 |
batch, |
| 776 |
batchCalls, |
| 777 |
schedule, |
| 778 |
setNotifyFunction, |
| 779 |
setBatchNotifyFunction |
| 780 |
}; |
| 781 |
} |
| 782 |
var notifyManager = createNotifyManager(); |
| 783 |
|
| 784 |
//# sourceMappingURL=notifyManager.js.map |
| 785 |
|
| 786 |
/***/ }), |
| 787 |
|
| 788 |
/***/ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js": |
| 789 |
/*!*************************************************************************!*\ |
| 790 |
!*** ./node_modules/@tanstack/query-core/build/modern/onlineManager.js ***! |
| 791 |
\*************************************************************************/ |
| 792 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 793 |
|
| 794 |
__webpack_require__.r(__webpack_exports__); |
| 795 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 796 |
/* harmony export */ OnlineManager: function() { return /* binding */ OnlineManager; }, |
| 797 |
/* harmony export */ onlineManager: function() { return /* binding */ onlineManager; } |
| 798 |
/* harmony export */ }); |
| 799 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 800 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 801 |
// src/onlineManager.ts |
| 802 |
|
| 803 |
|
| 804 |
var OnlineManager = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 805 |
#online = true; |
| 806 |
#cleanup; |
| 807 |
#setup; |
| 808 |
constructor() { |
| 809 |
super(); |
| 810 |
this.#setup = (onOnline) => { |
| 811 |
if (!_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { |
| 812 |
const onlineListener = () => onOnline(true); |
| 813 |
const offlineListener = () => onOnline(false); |
| 814 |
window.addEventListener("online", onlineListener, false); |
| 815 |
window.addEventListener("offline", offlineListener, false); |
| 816 |
return () => { |
| 817 |
window.removeEventListener("online", onlineListener); |
| 818 |
window.removeEventListener("offline", offlineListener); |
| 819 |
}; |
| 820 |
} |
| 821 |
return; |
| 822 |
}; |
| 823 |
} |
| 824 |
onSubscribe() { |
| 825 |
if (!this.#cleanup) { |
| 826 |
this.setEventListener(this.#setup); |
| 827 |
} |
| 828 |
} |
| 829 |
onUnsubscribe() { |
| 830 |
if (!this.hasListeners()) { |
| 831 |
this.#cleanup?.(); |
| 832 |
this.#cleanup = void 0; |
| 833 |
} |
| 834 |
} |
| 835 |
setEventListener(setup) { |
| 836 |
this.#setup = setup; |
| 837 |
this.#cleanup?.(); |
| 838 |
this.#cleanup = setup(this.setOnline.bind(this)); |
| 839 |
} |
| 840 |
setOnline(online) { |
| 841 |
const changed = this.#online !== online; |
| 842 |
if (changed) { |
| 843 |
this.#online = online; |
| 844 |
this.listeners.forEach((listener) => { |
| 845 |
listener(online); |
| 846 |
}); |
| 847 |
} |
| 848 |
} |
| 849 |
isOnline() { |
| 850 |
return this.#online; |
| 851 |
} |
| 852 |
}; |
| 853 |
var onlineManager = new OnlineManager(); |
| 854 |
|
| 855 |
//# sourceMappingURL=onlineManager.js.map |
| 856 |
|
| 857 |
/***/ }), |
| 858 |
|
| 859 |
/***/ "./node_modules/@tanstack/query-core/build/modern/query.js": |
| 860 |
/*!*****************************************************************!*\ |
| 861 |
!*** ./node_modules/@tanstack/query-core/build/modern/query.js ***! |
| 862 |
\*****************************************************************/ |
| 863 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 864 |
|
| 865 |
__webpack_require__.r(__webpack_exports__); |
| 866 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 867 |
/* harmony export */ Query: function() { return /* binding */ Query; } |
| 868 |
/* harmony export */ }); |
| 869 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 870 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 871 |
/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); |
| 872 |
/* harmony import */ var _removable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./removable.js */ "./node_modules/@tanstack/query-core/build/modern/removable.js"); |
| 873 |
// src/query.ts |
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
var Query = class extends _removable_js__WEBPACK_IMPORTED_MODULE_0__.Removable { |
| 879 |
constructor(config) { |
| 880 |
super(); |
| 881 |
this.#abortSignalConsumed = false; |
| 882 |
this.#defaultOptions = config.defaultOptions; |
| 883 |
this.#setOptions(config.options); |
| 884 |
this.#observers = []; |
| 885 |
this.#cache = config.cache; |
| 886 |
this.queryKey = config.queryKey; |
| 887 |
this.queryHash = config.queryHash; |
| 888 |
this.#initialState = config.state || getDefaultState(this.options); |
| 889 |
this.state = this.#initialState; |
| 890 |
this.scheduleGc(); |
| 891 |
} |
| 892 |
#initialState; |
| 893 |
#revertState; |
| 894 |
#cache; |
| 895 |
#promise; |
| 896 |
#retryer; |
| 897 |
#observers; |
| 898 |
#defaultOptions; |
| 899 |
#abortSignalConsumed; |
| 900 |
get meta() { |
| 901 |
return this.options.meta; |
| 902 |
} |
| 903 |
#setOptions(options) { |
| 904 |
this.options = { ...this.#defaultOptions, ...options }; |
| 905 |
this.updateGcTime(this.options.gcTime); |
| 906 |
} |
| 907 |
optionalRemove() { |
| 908 |
if (!this.#observers.length && this.state.fetchStatus === "idle") { |
| 909 |
this.#cache.remove(this); |
| 910 |
} |
| 911 |
} |
| 912 |
setData(newData, options) { |
| 913 |
const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.replaceData)(this.state.data, newData, this.options); |
| 914 |
this.#dispatch({ |
| 915 |
data, |
| 916 |
type: "success", |
| 917 |
dataUpdatedAt: options?.updatedAt, |
| 918 |
manual: options?.manual |
| 919 |
}); |
| 920 |
return data; |
| 921 |
} |
| 922 |
setState(state, setStateOptions) { |
| 923 |
this.#dispatch({ type: "setState", state, setStateOptions }); |
| 924 |
} |
| 925 |
cancel(options) { |
| 926 |
const promise = this.#promise; |
| 927 |
this.#retryer?.cancel(options); |
| 928 |
return promise ? promise.then(_utils_js__WEBPACK_IMPORTED_MODULE_1__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_1__.noop) : Promise.resolve(); |
| 929 |
} |
| 930 |
destroy() { |
| 931 |
super.destroy(); |
| 932 |
this.cancel({ silent: true }); |
| 933 |
} |
| 934 |
reset() { |
| 935 |
this.destroy(); |
| 936 |
this.setState(this.#initialState); |
| 937 |
} |
| 938 |
isActive() { |
| 939 |
return this.#observers.some( |
| 940 |
(observer) => observer.options.enabled !== false |
| 941 |
); |
| 942 |
} |
| 943 |
isDisabled() { |
| 944 |
return this.getObserversCount() > 0 && !this.isActive(); |
| 945 |
} |
| 946 |
isStale() { |
| 947 |
return this.state.isInvalidated || !this.state.dataUpdatedAt || this.#observers.some((observer) => observer.getCurrentResult().isStale); |
| 948 |
} |
| 949 |
isStaleByTime(staleTime = 0) { |
| 950 |
return this.state.isInvalidated || !this.state.dataUpdatedAt || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.timeUntilStale)(this.state.dataUpdatedAt, staleTime); |
| 951 |
} |
| 952 |
onFocus() { |
| 953 |
const observer = this.#observers.find((x) => x.shouldFetchOnWindowFocus()); |
| 954 |
observer?.refetch({ cancelRefetch: false }); |
| 955 |
this.#retryer?.continue(); |
| 956 |
} |
| 957 |
onOnline() { |
| 958 |
const observer = this.#observers.find((x) => x.shouldFetchOnReconnect()); |
| 959 |
observer?.refetch({ cancelRefetch: false }); |
| 960 |
this.#retryer?.continue(); |
| 961 |
} |
| 962 |
addObserver(observer) { |
| 963 |
if (!this.#observers.includes(observer)) { |
| 964 |
this.#observers.push(observer); |
| 965 |
this.clearGcTimeout(); |
| 966 |
this.#cache.notify({ type: "observerAdded", query: this, observer }); |
| 967 |
} |
| 968 |
} |
| 969 |
removeObserver(observer) { |
| 970 |
if (this.#observers.includes(observer)) { |
| 971 |
this.#observers = this.#observers.filter((x) => x !== observer); |
| 972 |
if (!this.#observers.length) { |
| 973 |
if (this.#retryer) { |
| 974 |
if (this.#abortSignalConsumed) { |
| 975 |
this.#retryer.cancel({ revert: true }); |
| 976 |
} else { |
| 977 |
this.#retryer.cancelRetry(); |
| 978 |
} |
| 979 |
} |
| 980 |
this.scheduleGc(); |
| 981 |
} |
| 982 |
this.#cache.notify({ type: "observerRemoved", query: this, observer }); |
| 983 |
} |
| 984 |
} |
| 985 |
getObserversCount() { |
| 986 |
return this.#observers.length; |
| 987 |
} |
| 988 |
invalidate() { |
| 989 |
if (!this.state.isInvalidated) { |
| 990 |
this.#dispatch({ type: "invalidate" }); |
| 991 |
} |
| 992 |
} |
| 993 |
fetch(options, fetchOptions) { |
| 994 |
if (this.state.fetchStatus !== "idle") { |
| 995 |
if (this.state.dataUpdatedAt && fetchOptions?.cancelRefetch) { |
| 996 |
this.cancel({ silent: true }); |
| 997 |
} else if (this.#promise) { |
| 998 |
this.#retryer?.continueRetry(); |
| 999 |
return this.#promise; |
| 1000 |
} |
| 1001 |
} |
| 1002 |
if (options) { |
| 1003 |
this.#setOptions(options); |
| 1004 |
} |
| 1005 |
if (!this.options.queryFn) { |
| 1006 |
const observer = this.#observers.find((x) => x.options.queryFn); |
| 1007 |
if (observer) { |
| 1008 |
this.#setOptions(observer.options); |
| 1009 |
} |
| 1010 |
} |
| 1011 |
if (true) { |
| 1012 |
if (!Array.isArray(this.options.queryKey)) { |
| 1013 |
console.error( |
| 1014 |
`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']` |
| 1015 |
); |
| 1016 |
} |
| 1017 |
} |
| 1018 |
const abortController = new AbortController(); |
| 1019 |
const queryFnContext = { |
| 1020 |
queryKey: this.queryKey, |
| 1021 |
meta: this.meta |
| 1022 |
}; |
| 1023 |
const addSignalProperty = (object) => { |
| 1024 |
Object.defineProperty(object, "signal", { |
| 1025 |
enumerable: true, |
| 1026 |
get: () => { |
| 1027 |
this.#abortSignalConsumed = true; |
| 1028 |
return abortController.signal; |
| 1029 |
} |
| 1030 |
}); |
| 1031 |
}; |
| 1032 |
addSignalProperty(queryFnContext); |
| 1033 |
const fetchFn = () => { |
| 1034 |
if (!this.options.queryFn) { |
| 1035 |
return Promise.reject( |
| 1036 |
new Error(`Missing queryFn: '${this.options.queryHash}'`) |
| 1037 |
); |
| 1038 |
} |
| 1039 |
this.#abortSignalConsumed = false; |
| 1040 |
if (this.options.persister) { |
| 1041 |
return this.options.persister( |
| 1042 |
this.options.queryFn, |
| 1043 |
queryFnContext, |
| 1044 |
this |
| 1045 |
); |
| 1046 |
} |
| 1047 |
return this.options.queryFn( |
| 1048 |
queryFnContext |
| 1049 |
); |
| 1050 |
}; |
| 1051 |
const context = { |
| 1052 |
fetchOptions, |
| 1053 |
options: this.options, |
| 1054 |
queryKey: this.queryKey, |
| 1055 |
state: this.state, |
| 1056 |
fetchFn |
| 1057 |
}; |
| 1058 |
addSignalProperty(context); |
| 1059 |
this.options.behavior?.onFetch( |
| 1060 |
context, |
| 1061 |
this |
| 1062 |
); |
| 1063 |
this.#revertState = this.state; |
| 1064 |
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) { |
| 1065 |
this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta }); |
| 1066 |
} |
| 1067 |
const onError = (error) => { |
| 1068 |
if (!((0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.isCancelledError)(error) && error.silent)) { |
| 1069 |
this.#dispatch({ |
| 1070 |
type: "error", |
| 1071 |
error |
| 1072 |
}); |
| 1073 |
} |
| 1074 |
if (!(0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.isCancelledError)(error)) { |
| 1075 |
this.#cache.config.onError?.( |
| 1076 |
error, |
| 1077 |
this |
| 1078 |
); |
| 1079 |
this.#cache.config.onSettled?.( |
| 1080 |
this.state.data, |
| 1081 |
error, |
| 1082 |
this |
| 1083 |
); |
| 1084 |
} |
| 1085 |
if (!this.isFetchingOptimistic) { |
| 1086 |
this.scheduleGc(); |
| 1087 |
} |
| 1088 |
this.isFetchingOptimistic = false; |
| 1089 |
}; |
| 1090 |
this.#retryer = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.createRetryer)({ |
| 1091 |
fn: context.fetchFn, |
| 1092 |
abort: abortController.abort.bind(abortController), |
| 1093 |
onSuccess: (data) => { |
| 1094 |
if (typeof data === "undefined") { |
| 1095 |
if (true) { |
| 1096 |
console.error( |
| 1097 |
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}` |
| 1098 |
); |
| 1099 |
} |
| 1100 |
onError(new Error(`${this.queryHash} data is undefined`)); |
| 1101 |
return; |
| 1102 |
} |
| 1103 |
this.setData(data); |
| 1104 |
this.#cache.config.onSuccess?.(data, this); |
| 1105 |
this.#cache.config.onSettled?.( |
| 1106 |
data, |
| 1107 |
this.state.error, |
| 1108 |
this |
| 1109 |
); |
| 1110 |
if (!this.isFetchingOptimistic) { |
| 1111 |
this.scheduleGc(); |
| 1112 |
} |
| 1113 |
this.isFetchingOptimistic = false; |
| 1114 |
}, |
| 1115 |
onError, |
| 1116 |
onFail: (failureCount, error) => { |
| 1117 |
this.#dispatch({ type: "failed", failureCount, error }); |
| 1118 |
}, |
| 1119 |
onPause: () => { |
| 1120 |
this.#dispatch({ type: "pause" }); |
| 1121 |
}, |
| 1122 |
onContinue: () => { |
| 1123 |
this.#dispatch({ type: "continue" }); |
| 1124 |
}, |
| 1125 |
retry: context.options.retry, |
| 1126 |
retryDelay: context.options.retryDelay, |
| 1127 |
networkMode: context.options.networkMode |
| 1128 |
}); |
| 1129 |
this.#promise = this.#retryer.promise; |
| 1130 |
return this.#promise; |
| 1131 |
} |
| 1132 |
#dispatch(action) { |
| 1133 |
const reducer = (state) => { |
| 1134 |
switch (action.type) { |
| 1135 |
case "failed": |
| 1136 |
return { |
| 1137 |
...state, |
| 1138 |
fetchFailureCount: action.failureCount, |
| 1139 |
fetchFailureReason: action.error |
| 1140 |
}; |
| 1141 |
case "pause": |
| 1142 |
return { |
| 1143 |
...state, |
| 1144 |
fetchStatus: "paused" |
| 1145 |
}; |
| 1146 |
case "continue": |
| 1147 |
return { |
| 1148 |
...state, |
| 1149 |
fetchStatus: "fetching" |
| 1150 |
}; |
| 1151 |
case "fetch": |
| 1152 |
return { |
| 1153 |
...state, |
| 1154 |
fetchFailureCount: 0, |
| 1155 |
fetchFailureReason: null, |
| 1156 |
fetchMeta: action.meta ?? null, |
| 1157 |
fetchStatus: (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.canFetch)(this.options.networkMode) ? "fetching" : "paused", |
| 1158 |
...!state.dataUpdatedAt && { |
| 1159 |
error: null, |
| 1160 |
status: "pending" |
| 1161 |
} |
| 1162 |
}; |
| 1163 |
case "success": |
| 1164 |
return { |
| 1165 |
...state, |
| 1166 |
data: action.data, |
| 1167 |
dataUpdateCount: state.dataUpdateCount + 1, |
| 1168 |
dataUpdatedAt: action.dataUpdatedAt ?? Date.now(), |
| 1169 |
error: null, |
| 1170 |
isInvalidated: false, |
| 1171 |
status: "success", |
| 1172 |
...!action.manual && { |
| 1173 |
fetchStatus: "idle", |
| 1174 |
fetchFailureCount: 0, |
| 1175 |
fetchFailureReason: null |
| 1176 |
} |
| 1177 |
}; |
| 1178 |
case "error": |
| 1179 |
const error = action.error; |
| 1180 |
if ((0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.isCancelledError)(error) && error.revert && this.#revertState) { |
| 1181 |
return { ...this.#revertState, fetchStatus: "idle" }; |
| 1182 |
} |
| 1183 |
return { |
| 1184 |
...state, |
| 1185 |
error, |
| 1186 |
errorUpdateCount: state.errorUpdateCount + 1, |
| 1187 |
errorUpdatedAt: Date.now(), |
| 1188 |
fetchFailureCount: state.fetchFailureCount + 1, |
| 1189 |
fetchFailureReason: error, |
| 1190 |
fetchStatus: "idle", |
| 1191 |
status: "error" |
| 1192 |
}; |
| 1193 |
case "invalidate": |
| 1194 |
return { |
| 1195 |
...state, |
| 1196 |
isInvalidated: true |
| 1197 |
}; |
| 1198 |
case "setState": |
| 1199 |
return { |
| 1200 |
...state, |
| 1201 |
...action.state |
| 1202 |
}; |
| 1203 |
} |
| 1204 |
}; |
| 1205 |
this.state = reducer(this.state); |
| 1206 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { |
| 1207 |
this.#observers.forEach((observer) => { |
| 1208 |
observer.onQueryUpdate(); |
| 1209 |
}); |
| 1210 |
this.#cache.notify({ query: this, type: "updated", action }); |
| 1211 |
}); |
| 1212 |
} |
| 1213 |
}; |
| 1214 |
function getDefaultState(options) { |
| 1215 |
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData; |
| 1216 |
const hasData = typeof data !== "undefined"; |
| 1217 |
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; |
| 1218 |
return { |
| 1219 |
data, |
| 1220 |
dataUpdateCount: 0, |
| 1221 |
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0, |
| 1222 |
error: null, |
| 1223 |
errorUpdateCount: 0, |
| 1224 |
errorUpdatedAt: 0, |
| 1225 |
fetchFailureCount: 0, |
| 1226 |
fetchFailureReason: null, |
| 1227 |
fetchMeta: null, |
| 1228 |
isInvalidated: false, |
| 1229 |
status: hasData ? "success" : "pending", |
| 1230 |
fetchStatus: "idle" |
| 1231 |
}; |
| 1232 |
} |
| 1233 |
|
| 1234 |
//# sourceMappingURL=query.js.map |
| 1235 |
|
| 1236 |
/***/ }), |
| 1237 |
|
| 1238 |
/***/ "./node_modules/@tanstack/query-core/build/modern/queryCache.js": |
| 1239 |
/*!**********************************************************************!*\ |
| 1240 |
!*** ./node_modules/@tanstack/query-core/build/modern/queryCache.js ***! |
| 1241 |
\**********************************************************************/ |
| 1242 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1243 |
|
| 1244 |
__webpack_require__.r(__webpack_exports__); |
| 1245 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1246 |
/* harmony export */ QueryCache: function() { return /* binding */ QueryCache; } |
| 1247 |
/* harmony export */ }); |
| 1248 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1249 |
/* harmony import */ var _query_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./query.js */ "./node_modules/@tanstack/query-core/build/modern/query.js"); |
| 1250 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1251 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 1252 |
// src/queryCache.ts |
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
var QueryCache = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 1258 |
constructor(config = {}) { |
| 1259 |
super(); |
| 1260 |
this.config = config; |
| 1261 |
this.#queries = /* @__PURE__ */ new Map(); |
| 1262 |
} |
| 1263 |
#queries; |
| 1264 |
build(client, options, state) { |
| 1265 |
const queryKey = options.queryKey; |
| 1266 |
const queryHash = options.queryHash ?? (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hashQueryKeyByOptions)(queryKey, options); |
| 1267 |
let query = this.get(queryHash); |
| 1268 |
if (!query) { |
| 1269 |
query = new _query_js__WEBPACK_IMPORTED_MODULE_2__.Query({ |
| 1270 |
cache: this, |
| 1271 |
queryKey, |
| 1272 |
queryHash, |
| 1273 |
options: client.defaultQueryOptions(options), |
| 1274 |
state, |
| 1275 |
defaultOptions: client.getQueryDefaults(queryKey) |
| 1276 |
}); |
| 1277 |
this.add(query); |
| 1278 |
} |
| 1279 |
return query; |
| 1280 |
} |
| 1281 |
add(query) { |
| 1282 |
if (!this.#queries.has(query.queryHash)) { |
| 1283 |
this.#queries.set(query.queryHash, query); |
| 1284 |
this.notify({ |
| 1285 |
type: "added", |
| 1286 |
query |
| 1287 |
}); |
| 1288 |
} |
| 1289 |
} |
| 1290 |
remove(query) { |
| 1291 |
const queryInMap = this.#queries.get(query.queryHash); |
| 1292 |
if (queryInMap) { |
| 1293 |
query.destroy(); |
| 1294 |
if (queryInMap === query) { |
| 1295 |
this.#queries.delete(query.queryHash); |
| 1296 |
} |
| 1297 |
this.notify({ type: "removed", query }); |
| 1298 |
} |
| 1299 |
} |
| 1300 |
clear() { |
| 1301 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { |
| 1302 |
this.getAll().forEach((query) => { |
| 1303 |
this.remove(query); |
| 1304 |
}); |
| 1305 |
}); |
| 1306 |
} |
| 1307 |
get(queryHash) { |
| 1308 |
return this.#queries.get(queryHash); |
| 1309 |
} |
| 1310 |
getAll() { |
| 1311 |
return [...this.#queries.values()]; |
| 1312 |
} |
| 1313 |
find(filters) { |
| 1314 |
const defaultedFilters = { exact: true, ...filters }; |
| 1315 |
return this.getAll().find( |
| 1316 |
(query) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.matchQuery)(defaultedFilters, query) |
| 1317 |
); |
| 1318 |
} |
| 1319 |
findAll(filters = {}) { |
| 1320 |
const queries = this.getAll(); |
| 1321 |
return Object.keys(filters).length > 0 ? queries.filter((query) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.matchQuery)(filters, query)) : queries; |
| 1322 |
} |
| 1323 |
notify(event) { |
| 1324 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { |
| 1325 |
this.listeners.forEach((listener) => { |
| 1326 |
listener(event); |
| 1327 |
}); |
| 1328 |
}); |
| 1329 |
} |
| 1330 |
onFocus() { |
| 1331 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { |
| 1332 |
this.getAll().forEach((query) => { |
| 1333 |
query.onFocus(); |
| 1334 |
}); |
| 1335 |
}); |
| 1336 |
} |
| 1337 |
onOnline() { |
| 1338 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batch(() => { |
| 1339 |
this.getAll().forEach((query) => { |
| 1340 |
query.onOnline(); |
| 1341 |
}); |
| 1342 |
}); |
| 1343 |
} |
| 1344 |
}; |
| 1345 |
|
| 1346 |
//# sourceMappingURL=queryCache.js.map |
| 1347 |
|
| 1348 |
/***/ }), |
| 1349 |
|
| 1350 |
/***/ "./node_modules/@tanstack/query-core/build/modern/queryClient.js": |
| 1351 |
/*!***********************************************************************!*\ |
| 1352 |
!*** ./node_modules/@tanstack/query-core/build/modern/queryClient.js ***! |
| 1353 |
\***********************************************************************/ |
| 1354 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1355 |
|
| 1356 |
__webpack_require__.r(__webpack_exports__); |
| 1357 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1358 |
/* harmony export */ QueryClient: function() { return /* binding */ QueryClient; } |
| 1359 |
/* harmony export */ }); |
| 1360 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1361 |
/* harmony import */ var _queryCache_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./queryCache.js */ "./node_modules/@tanstack/query-core/build/modern/queryCache.js"); |
| 1362 |
/* harmony import */ var _mutationCache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutationCache.js */ "./node_modules/@tanstack/query-core/build/modern/mutationCache.js"); |
| 1363 |
/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); |
| 1364 |
/* harmony import */ var _onlineManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./onlineManager.js */ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js"); |
| 1365 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1366 |
/* harmony import */ var _infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./infiniteQueryBehavior.js */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js"); |
| 1367 |
// src/queryClient.ts |
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
var QueryClient = class { |
| 1376 |
#queryCache; |
| 1377 |
#mutationCache; |
| 1378 |
#defaultOptions; |
| 1379 |
#queryDefaults; |
| 1380 |
#mutationDefaults; |
| 1381 |
#mountCount; |
| 1382 |
#unsubscribeFocus; |
| 1383 |
#unsubscribeOnline; |
| 1384 |
constructor(config = {}) { |
| 1385 |
this.#queryCache = config.queryCache || new _queryCache_js__WEBPACK_IMPORTED_MODULE_0__.QueryCache(); |
| 1386 |
this.#mutationCache = config.mutationCache || new _mutationCache_js__WEBPACK_IMPORTED_MODULE_1__.MutationCache(); |
| 1387 |
this.#defaultOptions = config.defaultOptions || {}; |
| 1388 |
this.#queryDefaults = /* @__PURE__ */ new Map(); |
| 1389 |
this.#mutationDefaults = /* @__PURE__ */ new Map(); |
| 1390 |
this.#mountCount = 0; |
| 1391 |
} |
| 1392 |
mount() { |
| 1393 |
this.#mountCount++; |
| 1394 |
if (this.#mountCount !== 1) |
| 1395 |
return; |
| 1396 |
this.#unsubscribeFocus = _focusManager_js__WEBPACK_IMPORTED_MODULE_2__.focusManager.subscribe(() => { |
| 1397 |
if (_focusManager_js__WEBPACK_IMPORTED_MODULE_2__.focusManager.isFocused()) { |
| 1398 |
this.resumePausedMutations(); |
| 1399 |
this.#queryCache.onFocus(); |
| 1400 |
} |
| 1401 |
}); |
| 1402 |
this.#unsubscribeOnline = _onlineManager_js__WEBPACK_IMPORTED_MODULE_3__.onlineManager.subscribe(() => { |
| 1403 |
if (_onlineManager_js__WEBPACK_IMPORTED_MODULE_3__.onlineManager.isOnline()) { |
| 1404 |
this.resumePausedMutations(); |
| 1405 |
this.#queryCache.onOnline(); |
| 1406 |
} |
| 1407 |
}); |
| 1408 |
} |
| 1409 |
unmount() { |
| 1410 |
this.#mountCount--; |
| 1411 |
if (this.#mountCount !== 0) |
| 1412 |
return; |
| 1413 |
this.#unsubscribeFocus?.(); |
| 1414 |
this.#unsubscribeFocus = void 0; |
| 1415 |
this.#unsubscribeOnline?.(); |
| 1416 |
this.#unsubscribeOnline = void 0; |
| 1417 |
} |
| 1418 |
isFetching(filters) { |
| 1419 |
return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length; |
| 1420 |
} |
| 1421 |
isMutating(filters) { |
| 1422 |
return this.#mutationCache.findAll({ ...filters, status: "pending" }).length; |
| 1423 |
} |
| 1424 |
getQueryData(queryKey) { |
| 1425 |
return this.#queryCache.find({ queryKey })?.state.data; |
| 1426 |
} |
| 1427 |
ensureQueryData(options) { |
| 1428 |
const cachedData = this.getQueryData(options.queryKey); |
| 1429 |
return cachedData !== void 0 ? Promise.resolve(cachedData) : this.fetchQuery(options); |
| 1430 |
} |
| 1431 |
getQueriesData(filters) { |
| 1432 |
return this.getQueryCache().findAll(filters).map(({ queryKey, state }) => { |
| 1433 |
const data = state.data; |
| 1434 |
return [queryKey, data]; |
| 1435 |
}); |
| 1436 |
} |
| 1437 |
setQueryData(queryKey, updater, options) { |
| 1438 |
const query = this.#queryCache.find({ queryKey }); |
| 1439 |
const prevData = query?.state.data; |
| 1440 |
const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.functionalUpdate)(updater, prevData); |
| 1441 |
if (typeof data === "undefined") { |
| 1442 |
return void 0; |
| 1443 |
} |
| 1444 |
const defaultedOptions = this.defaultQueryOptions({ queryKey }); |
| 1445 |
return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true }); |
| 1446 |
} |
| 1447 |
setQueriesData(filters, updater, options) { |
| 1448 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( |
| 1449 |
() => this.getQueryCache().findAll(filters).map(({ queryKey }) => [ |
| 1450 |
queryKey, |
| 1451 |
this.setQueryData(queryKey, updater, options) |
| 1452 |
]) |
| 1453 |
); |
| 1454 |
} |
| 1455 |
getQueryState(queryKey) { |
| 1456 |
return this.#queryCache.find({ queryKey })?.state; |
| 1457 |
} |
| 1458 |
removeQueries(filters) { |
| 1459 |
const queryCache = this.#queryCache; |
| 1460 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { |
| 1461 |
queryCache.findAll(filters).forEach((query) => { |
| 1462 |
queryCache.remove(query); |
| 1463 |
}); |
| 1464 |
}); |
| 1465 |
} |
| 1466 |
resetQueries(filters, options) { |
| 1467 |
const queryCache = this.#queryCache; |
| 1468 |
const refetchFilters = { |
| 1469 |
type: "active", |
| 1470 |
...filters |
| 1471 |
}; |
| 1472 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { |
| 1473 |
queryCache.findAll(filters).forEach((query) => { |
| 1474 |
query.reset(); |
| 1475 |
}); |
| 1476 |
return this.refetchQueries(refetchFilters, options); |
| 1477 |
}); |
| 1478 |
} |
| 1479 |
cancelQueries(filters = {}, cancelOptions = {}) { |
| 1480 |
const defaultedCancelOptions = { revert: true, ...cancelOptions }; |
| 1481 |
const promises = _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( |
| 1482 |
() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)) |
| 1483 |
); |
| 1484 |
return Promise.all(promises).then(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop); |
| 1485 |
} |
| 1486 |
invalidateQueries(filters = {}, options = {}) { |
| 1487 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { |
| 1488 |
this.#queryCache.findAll(filters).forEach((query) => { |
| 1489 |
query.invalidate(); |
| 1490 |
}); |
| 1491 |
if (filters.refetchType === "none") { |
| 1492 |
return Promise.resolve(); |
| 1493 |
} |
| 1494 |
const refetchFilters = { |
| 1495 |
...filters, |
| 1496 |
type: filters.refetchType ?? filters.type ?? "active" |
| 1497 |
}; |
| 1498 |
return this.refetchQueries(refetchFilters, options); |
| 1499 |
}); |
| 1500 |
} |
| 1501 |
refetchQueries(filters = {}, options) { |
| 1502 |
const fetchOptions = { |
| 1503 |
...options, |
| 1504 |
cancelRefetch: options?.cancelRefetch ?? true |
| 1505 |
}; |
| 1506 |
const promises = _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( |
| 1507 |
() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled()).map((query) => { |
| 1508 |
let promise = query.fetch(void 0, fetchOptions); |
| 1509 |
if (!fetchOptions.throwOnError) { |
| 1510 |
promise = promise.catch(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop); |
| 1511 |
} |
| 1512 |
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise; |
| 1513 |
}) |
| 1514 |
); |
| 1515 |
return Promise.all(promises).then(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop); |
| 1516 |
} |
| 1517 |
fetchQuery(options) { |
| 1518 |
const defaultedOptions = this.defaultQueryOptions(options); |
| 1519 |
if (typeof defaultedOptions.retry === "undefined") { |
| 1520 |
defaultedOptions.retry = false; |
| 1521 |
} |
| 1522 |
const query = this.#queryCache.build(this, defaultedOptions); |
| 1523 |
return query.isStaleByTime(defaultedOptions.staleTime) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); |
| 1524 |
} |
| 1525 |
prefetchQuery(options) { |
| 1526 |
return this.fetchQuery(options).then(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop); |
| 1527 |
} |
| 1528 |
fetchInfiniteQuery(options) { |
| 1529 |
options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__.infiniteQueryBehavior)(options.pages); |
| 1530 |
return this.fetchQuery(options); |
| 1531 |
} |
| 1532 |
prefetchInfiniteQuery(options) { |
| 1533 |
return this.fetchInfiniteQuery(options).then(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_4__.noop); |
| 1534 |
} |
| 1535 |
resumePausedMutations() { |
| 1536 |
return this.#mutationCache.resumePausedMutations(); |
| 1537 |
} |
| 1538 |
getQueryCache() { |
| 1539 |
return this.#queryCache; |
| 1540 |
} |
| 1541 |
getMutationCache() { |
| 1542 |
return this.#mutationCache; |
| 1543 |
} |
| 1544 |
getDefaultOptions() { |
| 1545 |
return this.#defaultOptions; |
| 1546 |
} |
| 1547 |
setDefaultOptions(options) { |
| 1548 |
this.#defaultOptions = options; |
| 1549 |
} |
| 1550 |
setQueryDefaults(queryKey, options) { |
| 1551 |
this.#queryDefaults.set((0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.hashKey)(queryKey), { |
| 1552 |
queryKey, |
| 1553 |
defaultOptions: options |
| 1554 |
}); |
| 1555 |
} |
| 1556 |
getQueryDefaults(queryKey) { |
| 1557 |
const defaults = [...this.#queryDefaults.values()]; |
| 1558 |
let result = {}; |
| 1559 |
defaults.forEach((queryDefault) => { |
| 1560 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.partialMatchKey)(queryKey, queryDefault.queryKey)) { |
| 1561 |
result = { ...result, ...queryDefault.defaultOptions }; |
| 1562 |
} |
| 1563 |
}); |
| 1564 |
return result; |
| 1565 |
} |
| 1566 |
setMutationDefaults(mutationKey, options) { |
| 1567 |
this.#mutationDefaults.set((0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.hashKey)(mutationKey), { |
| 1568 |
mutationKey, |
| 1569 |
defaultOptions: options |
| 1570 |
}); |
| 1571 |
} |
| 1572 |
getMutationDefaults(mutationKey) { |
| 1573 |
const defaults = [...this.#mutationDefaults.values()]; |
| 1574 |
let result = {}; |
| 1575 |
defaults.forEach((queryDefault) => { |
| 1576 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.partialMatchKey)(mutationKey, queryDefault.mutationKey)) { |
| 1577 |
result = { ...result, ...queryDefault.defaultOptions }; |
| 1578 |
} |
| 1579 |
}); |
| 1580 |
return result; |
| 1581 |
} |
| 1582 |
defaultQueryOptions(options) { |
| 1583 |
if (options?._defaulted) { |
| 1584 |
return options; |
| 1585 |
} |
| 1586 |
const defaultedOptions = { |
| 1587 |
...this.#defaultOptions.queries, |
| 1588 |
...options?.queryKey && this.getQueryDefaults(options.queryKey), |
| 1589 |
...options, |
| 1590 |
_defaulted: true |
| 1591 |
}; |
| 1592 |
if (!defaultedOptions.queryHash) { |
| 1593 |
defaultedOptions.queryHash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.hashQueryKeyByOptions)( |
| 1594 |
defaultedOptions.queryKey, |
| 1595 |
defaultedOptions |
| 1596 |
); |
| 1597 |
} |
| 1598 |
if (typeof defaultedOptions.refetchOnReconnect === "undefined") { |
| 1599 |
defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always"; |
| 1600 |
} |
| 1601 |
if (typeof defaultedOptions.throwOnError === "undefined") { |
| 1602 |
defaultedOptions.throwOnError = !!defaultedOptions.suspense; |
| 1603 |
} |
| 1604 |
if (typeof defaultedOptions.networkMode === "undefined" && defaultedOptions.persister) { |
| 1605 |
defaultedOptions.networkMode = "offlineFirst"; |
| 1606 |
} |
| 1607 |
return defaultedOptions; |
| 1608 |
} |
| 1609 |
defaultMutationOptions(options) { |
| 1610 |
if (options?._defaulted) { |
| 1611 |
return options; |
| 1612 |
} |
| 1613 |
return { |
| 1614 |
...this.#defaultOptions.mutations, |
| 1615 |
...options?.mutationKey && this.getMutationDefaults(options.mutationKey), |
| 1616 |
...options, |
| 1617 |
_defaulted: true |
| 1618 |
}; |
| 1619 |
} |
| 1620 |
clear() { |
| 1621 |
this.#queryCache.clear(); |
| 1622 |
this.#mutationCache.clear(); |
| 1623 |
} |
| 1624 |
}; |
| 1625 |
|
| 1626 |
//# sourceMappingURL=queryClient.js.map |
| 1627 |
|
| 1628 |
/***/ }), |
| 1629 |
|
| 1630 |
/***/ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js": |
| 1631 |
/*!*************************************************************************!*\ |
| 1632 |
!*** ./node_modules/@tanstack/query-core/build/modern/queryObserver.js ***! |
| 1633 |
\*************************************************************************/ |
| 1634 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1635 |
|
| 1636 |
__webpack_require__.r(__webpack_exports__); |
| 1637 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1638 |
/* harmony export */ QueryObserver: function() { return /* binding */ QueryObserver; } |
| 1639 |
/* harmony export */ }); |
| 1640 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1641 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1642 |
/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); |
| 1643 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 1644 |
/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); |
| 1645 |
// src/queryObserver.ts |
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
var QueryObserver = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 1652 |
constructor(client, options) { |
| 1653 |
super(); |
| 1654 |
this.#currentQuery = void 0; |
| 1655 |
this.#currentQueryInitialState = void 0; |
| 1656 |
this.#currentResult = void 0; |
| 1657 |
this.#trackedProps = /* @__PURE__ */ new Set(); |
| 1658 |
this.#client = client; |
| 1659 |
this.options = options; |
| 1660 |
this.#selectError = null; |
| 1661 |
this.bindMethods(); |
| 1662 |
this.setOptions(options); |
| 1663 |
} |
| 1664 |
#client; |
| 1665 |
#currentQuery; |
| 1666 |
#currentQueryInitialState; |
| 1667 |
#currentResult; |
| 1668 |
#currentResultState; |
| 1669 |
#currentResultOptions; |
| 1670 |
#selectError; |
| 1671 |
#selectFn; |
| 1672 |
#selectResult; |
| 1673 |
// This property keeps track of the last query with defined data. |
| 1674 |
// It will be used to pass the previous data and query to the placeholder function between renders. |
| 1675 |
#lastQueryWithDefinedData; |
| 1676 |
#staleTimeoutId; |
| 1677 |
#refetchIntervalId; |
| 1678 |
#currentRefetchInterval; |
| 1679 |
#trackedProps; |
| 1680 |
bindMethods() { |
| 1681 |
this.refetch = this.refetch.bind(this); |
| 1682 |
} |
| 1683 |
onSubscribe() { |
| 1684 |
if (this.listeners.size === 1) { |
| 1685 |
this.#currentQuery.addObserver(this); |
| 1686 |
if (shouldFetchOnMount(this.#currentQuery, this.options)) { |
| 1687 |
this.#executeFetch(); |
| 1688 |
} |
| 1689 |
this.#updateTimers(); |
| 1690 |
} |
| 1691 |
} |
| 1692 |
onUnsubscribe() { |
| 1693 |
if (!this.hasListeners()) { |
| 1694 |
this.destroy(); |
| 1695 |
} |
| 1696 |
} |
| 1697 |
shouldFetchOnReconnect() { |
| 1698 |
return shouldFetchOn( |
| 1699 |
this.#currentQuery, |
| 1700 |
this.options, |
| 1701 |
this.options.refetchOnReconnect |
| 1702 |
); |
| 1703 |
} |
| 1704 |
shouldFetchOnWindowFocus() { |
| 1705 |
return shouldFetchOn( |
| 1706 |
this.#currentQuery, |
| 1707 |
this.options, |
| 1708 |
this.options.refetchOnWindowFocus |
| 1709 |
); |
| 1710 |
} |
| 1711 |
destroy() { |
| 1712 |
this.listeners = /* @__PURE__ */ new Set(); |
| 1713 |
this.#clearStaleTimeout(); |
| 1714 |
this.#clearRefetchInterval(); |
| 1715 |
this.#currentQuery.removeObserver(this); |
| 1716 |
} |
| 1717 |
setOptions(options, notifyOptions) { |
| 1718 |
const prevOptions = this.options; |
| 1719 |
const prevQuery = this.#currentQuery; |
| 1720 |
this.options = this.#client.defaultQueryOptions(options); |
| 1721 |
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(prevOptions, this.options)) { |
| 1722 |
this.#client.getQueryCache().notify({ |
| 1723 |
type: "observerOptionsUpdated", |
| 1724 |
query: this.#currentQuery, |
| 1725 |
observer: this |
| 1726 |
}); |
| 1727 |
} |
| 1728 |
if (typeof this.options.enabled !== "undefined" && typeof this.options.enabled !== "boolean") { |
| 1729 |
throw new Error("Expected enabled to be a boolean"); |
| 1730 |
} |
| 1731 |
if (!this.options.queryKey) { |
| 1732 |
this.options.queryKey = prevOptions.queryKey; |
| 1733 |
} |
| 1734 |
this.#updateQuery(); |
| 1735 |
const mounted = this.hasListeners(); |
| 1736 |
if (mounted && shouldFetchOptionally( |
| 1737 |
this.#currentQuery, |
| 1738 |
prevQuery, |
| 1739 |
this.options, |
| 1740 |
prevOptions |
| 1741 |
)) { |
| 1742 |
this.#executeFetch(); |
| 1743 |
} |
| 1744 |
this.updateResult(notifyOptions); |
| 1745 |
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) { |
| 1746 |
this.#updateStaleTimeout(); |
| 1747 |
} |
| 1748 |
const nextRefetchInterval = this.#computeRefetchInterval(); |
| 1749 |
if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.#currentRefetchInterval)) { |
| 1750 |
this.#updateRefetchInterval(nextRefetchInterval); |
| 1751 |
} |
| 1752 |
} |
| 1753 |
getOptimisticResult(options) { |
| 1754 |
const query = this.#client.getQueryCache().build(this.#client, options); |
| 1755 |
const result = this.createResult(query, options); |
| 1756 |
if (shouldAssignObserverCurrentProperties(this, result)) { |
| 1757 |
this.#currentResult = result; |
| 1758 |
this.#currentResultOptions = this.options; |
| 1759 |
this.#currentResultState = this.#currentQuery.state; |
| 1760 |
} |
| 1761 |
return result; |
| 1762 |
} |
| 1763 |
getCurrentResult() { |
| 1764 |
return this.#currentResult; |
| 1765 |
} |
| 1766 |
trackResult(result) { |
| 1767 |
const trackedResult = {}; |
| 1768 |
Object.keys(result).forEach((key) => { |
| 1769 |
Object.defineProperty(trackedResult, key, { |
| 1770 |
configurable: false, |
| 1771 |
enumerable: true, |
| 1772 |
get: () => { |
| 1773 |
this.#trackedProps.add(key); |
| 1774 |
return result[key]; |
| 1775 |
} |
| 1776 |
}); |
| 1777 |
}); |
| 1778 |
return trackedResult; |
| 1779 |
} |
| 1780 |
getCurrentQuery() { |
| 1781 |
return this.#currentQuery; |
| 1782 |
} |
| 1783 |
refetch({ ...options } = {}) { |
| 1784 |
return this.fetch({ |
| 1785 |
...options |
| 1786 |
}); |
| 1787 |
} |
| 1788 |
fetchOptimistic(options) { |
| 1789 |
const defaultedOptions = this.#client.defaultQueryOptions(options); |
| 1790 |
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions); |
| 1791 |
query.isFetchingOptimistic = true; |
| 1792 |
return query.fetch().then(() => this.createResult(query, defaultedOptions)); |
| 1793 |
} |
| 1794 |
fetch(fetchOptions) { |
| 1795 |
return this.#executeFetch({ |
| 1796 |
...fetchOptions, |
| 1797 |
cancelRefetch: fetchOptions.cancelRefetch ?? true |
| 1798 |
}).then(() => { |
| 1799 |
this.updateResult(); |
| 1800 |
return this.#currentResult; |
| 1801 |
}); |
| 1802 |
} |
| 1803 |
#executeFetch(fetchOptions) { |
| 1804 |
this.#updateQuery(); |
| 1805 |
let promise = this.#currentQuery.fetch( |
| 1806 |
this.options, |
| 1807 |
fetchOptions |
| 1808 |
); |
| 1809 |
if (!fetchOptions?.throwOnError) { |
| 1810 |
promise = promise.catch(_utils_js__WEBPACK_IMPORTED_MODULE_1__.noop); |
| 1811 |
} |
| 1812 |
return promise; |
| 1813 |
} |
| 1814 |
#updateStaleTimeout() { |
| 1815 |
this.#clearStaleTimeout(); |
| 1816 |
if (_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer || this.#currentResult.isStale || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.options.staleTime)) { |
| 1817 |
return; |
| 1818 |
} |
| 1819 |
const time = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.timeUntilStale)( |
| 1820 |
this.#currentResult.dataUpdatedAt, |
| 1821 |
this.options.staleTime |
| 1822 |
); |
| 1823 |
const timeout = time + 1; |
| 1824 |
this.#staleTimeoutId = setTimeout(() => { |
| 1825 |
if (!this.#currentResult.isStale) { |
| 1826 |
this.updateResult(); |
| 1827 |
} |
| 1828 |
}, timeout); |
| 1829 |
} |
| 1830 |
#computeRefetchInterval() { |
| 1831 |
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false; |
| 1832 |
} |
| 1833 |
#updateRefetchInterval(nextInterval) { |
| 1834 |
this.#clearRefetchInterval(); |
| 1835 |
this.#currentRefetchInterval = nextInterval; |
| 1836 |
if (_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer || this.options.enabled === false || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) { |
| 1837 |
return; |
| 1838 |
} |
| 1839 |
this.#refetchIntervalId = setInterval(() => { |
| 1840 |
if (this.options.refetchIntervalInBackground || _focusManager_js__WEBPACK_IMPORTED_MODULE_2__.focusManager.isFocused()) { |
| 1841 |
this.#executeFetch(); |
| 1842 |
} |
| 1843 |
}, this.#currentRefetchInterval); |
| 1844 |
} |
| 1845 |
#updateTimers() { |
| 1846 |
this.#updateStaleTimeout(); |
| 1847 |
this.#updateRefetchInterval(this.#computeRefetchInterval()); |
| 1848 |
} |
| 1849 |
#clearStaleTimeout() { |
| 1850 |
if (this.#staleTimeoutId) { |
| 1851 |
clearTimeout(this.#staleTimeoutId); |
| 1852 |
this.#staleTimeoutId = void 0; |
| 1853 |
} |
| 1854 |
} |
| 1855 |
#clearRefetchInterval() { |
| 1856 |
if (this.#refetchIntervalId) { |
| 1857 |
clearInterval(this.#refetchIntervalId); |
| 1858 |
this.#refetchIntervalId = void 0; |
| 1859 |
} |
| 1860 |
} |
| 1861 |
createResult(query, options) { |
| 1862 |
const prevQuery = this.#currentQuery; |
| 1863 |
const prevOptions = this.options; |
| 1864 |
const prevResult = this.#currentResult; |
| 1865 |
const prevResultState = this.#currentResultState; |
| 1866 |
const prevResultOptions = this.#currentResultOptions; |
| 1867 |
const queryChange = query !== prevQuery; |
| 1868 |
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState; |
| 1869 |
const { state } = query; |
| 1870 |
let { error, errorUpdatedAt, fetchStatus, status } = state; |
| 1871 |
let isPlaceholderData = false; |
| 1872 |
let data; |
| 1873 |
if (options._optimisticResults) { |
| 1874 |
const mounted = this.hasListeners(); |
| 1875 |
const fetchOnMount = !mounted && shouldFetchOnMount(query, options); |
| 1876 |
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions); |
| 1877 |
if (fetchOnMount || fetchOptionally) { |
| 1878 |
fetchStatus = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_3__.canFetch)(query.options.networkMode) ? "fetching" : "paused"; |
| 1879 |
if (!state.dataUpdatedAt) { |
| 1880 |
status = "pending"; |
| 1881 |
} |
| 1882 |
} |
| 1883 |
if (options._optimisticResults === "isRestoring") { |
| 1884 |
fetchStatus = "idle"; |
| 1885 |
} |
| 1886 |
} |
| 1887 |
if (options.select && typeof state.data !== "undefined") { |
| 1888 |
if (prevResult && state.data === prevResultState?.data && options.select === this.#selectFn) { |
| 1889 |
data = this.#selectResult; |
| 1890 |
} else { |
| 1891 |
try { |
| 1892 |
this.#selectFn = options.select; |
| 1893 |
data = options.select(state.data); |
| 1894 |
data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.replaceData)(prevResult?.data, data, options); |
| 1895 |
this.#selectResult = data; |
| 1896 |
this.#selectError = null; |
| 1897 |
} catch (selectError) { |
| 1898 |
this.#selectError = selectError; |
| 1899 |
} |
| 1900 |
} |
| 1901 |
} else { |
| 1902 |
data = state.data; |
| 1903 |
} |
| 1904 |
if (typeof options.placeholderData !== "undefined" && typeof data === "undefined" && status === "pending") { |
| 1905 |
let placeholderData; |
| 1906 |
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) { |
| 1907 |
placeholderData = prevResult.data; |
| 1908 |
} else { |
| 1909 |
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData( |
| 1910 |
this.#lastQueryWithDefinedData?.state.data, |
| 1911 |
this.#lastQueryWithDefinedData |
| 1912 |
) : options.placeholderData; |
| 1913 |
if (options.select && typeof placeholderData !== "undefined") { |
| 1914 |
try { |
| 1915 |
placeholderData = options.select(placeholderData); |
| 1916 |
this.#selectError = null; |
| 1917 |
} catch (selectError) { |
| 1918 |
this.#selectError = selectError; |
| 1919 |
} |
| 1920 |
} |
| 1921 |
} |
| 1922 |
if (typeof placeholderData !== "undefined") { |
| 1923 |
status = "success"; |
| 1924 |
data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.replaceData)( |
| 1925 |
prevResult?.data, |
| 1926 |
placeholderData, |
| 1927 |
options |
| 1928 |
); |
| 1929 |
isPlaceholderData = true; |
| 1930 |
} |
| 1931 |
} |
| 1932 |
if (this.#selectError) { |
| 1933 |
error = this.#selectError; |
| 1934 |
data = this.#selectResult; |
| 1935 |
errorUpdatedAt = Date.now(); |
| 1936 |
status = "error"; |
| 1937 |
} |
| 1938 |
const isFetching = fetchStatus === "fetching"; |
| 1939 |
const isPending = status === "pending"; |
| 1940 |
const isError = status === "error"; |
| 1941 |
const isLoading = isPending && isFetching; |
| 1942 |
const result = { |
| 1943 |
status, |
| 1944 |
fetchStatus, |
| 1945 |
isPending, |
| 1946 |
isSuccess: status === "success", |
| 1947 |
isError, |
| 1948 |
isInitialLoading: isLoading, |
| 1949 |
isLoading, |
| 1950 |
data, |
| 1951 |
dataUpdatedAt: state.dataUpdatedAt, |
| 1952 |
error, |
| 1953 |
errorUpdatedAt, |
| 1954 |
failureCount: state.fetchFailureCount, |
| 1955 |
failureReason: state.fetchFailureReason, |
| 1956 |
errorUpdateCount: state.errorUpdateCount, |
| 1957 |
isFetched: state.dataUpdateCount > 0 || state.errorUpdateCount > 0, |
| 1958 |
isFetchedAfterMount: state.dataUpdateCount > queryInitialState.dataUpdateCount || state.errorUpdateCount > queryInitialState.errorUpdateCount, |
| 1959 |
isFetching, |
| 1960 |
isRefetching: isFetching && !isPending, |
| 1961 |
isLoadingError: isError && state.dataUpdatedAt === 0, |
| 1962 |
isPaused: fetchStatus === "paused", |
| 1963 |
isPlaceholderData, |
| 1964 |
isRefetchError: isError && state.dataUpdatedAt !== 0, |
| 1965 |
isStale: isStale(query, options), |
| 1966 |
refetch: this.refetch |
| 1967 |
}; |
| 1968 |
return result; |
| 1969 |
} |
| 1970 |
updateResult(notifyOptions) { |
| 1971 |
const prevResult = this.#currentResult; |
| 1972 |
const nextResult = this.createResult(this.#currentQuery, this.options); |
| 1973 |
this.#currentResultState = this.#currentQuery.state; |
| 1974 |
this.#currentResultOptions = this.options; |
| 1975 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(nextResult, prevResult)) { |
| 1976 |
return; |
| 1977 |
} |
| 1978 |
if (this.#currentResultState.data !== void 0) { |
| 1979 |
this.#lastQueryWithDefinedData = this.#currentQuery; |
| 1980 |
} |
| 1981 |
this.#currentResult = nextResult; |
| 1982 |
const defaultNotifyOptions = {}; |
| 1983 |
const shouldNotifyListeners = () => { |
| 1984 |
if (!prevResult) { |
| 1985 |
return true; |
| 1986 |
} |
| 1987 |
const { notifyOnChangeProps } = this.options; |
| 1988 |
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps; |
| 1989 |
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) { |
| 1990 |
return true; |
| 1991 |
} |
| 1992 |
const includedProps = new Set( |
| 1993 |
notifyOnChangePropsValue ?? this.#trackedProps |
| 1994 |
); |
| 1995 |
if (this.options.throwOnError) { |
| 1996 |
includedProps.add("error"); |
| 1997 |
} |
| 1998 |
return Object.keys(this.#currentResult).some((key) => { |
| 1999 |
const typedKey = key; |
| 2000 |
const changed = this.#currentResult[typedKey] !== prevResult[typedKey]; |
| 2001 |
return changed && includedProps.has(typedKey); |
| 2002 |
}); |
| 2003 |
}; |
| 2004 |
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) { |
| 2005 |
defaultNotifyOptions.listeners = true; |
| 2006 |
} |
| 2007 |
this.#notify({ ...defaultNotifyOptions, ...notifyOptions }); |
| 2008 |
} |
| 2009 |
#updateQuery() { |
| 2010 |
const query = this.#client.getQueryCache().build(this.#client, this.options); |
| 2011 |
if (query === this.#currentQuery) { |
| 2012 |
return; |
| 2013 |
} |
| 2014 |
const prevQuery = this.#currentQuery; |
| 2015 |
this.#currentQuery = query; |
| 2016 |
this.#currentQueryInitialState = query.state; |
| 2017 |
if (this.hasListeners()) { |
| 2018 |
prevQuery?.removeObserver(this); |
| 2019 |
query.addObserver(this); |
| 2020 |
} |
| 2021 |
} |
| 2022 |
onQueryUpdate() { |
| 2023 |
this.updateResult(); |
| 2024 |
if (this.hasListeners()) { |
| 2025 |
this.#updateTimers(); |
| 2026 |
} |
| 2027 |
} |
| 2028 |
#notify(notifyOptions) { |
| 2029 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_4__.notifyManager.batch(() => { |
| 2030 |
if (notifyOptions.listeners) { |
| 2031 |
this.listeners.forEach((listener) => { |
| 2032 |
listener(this.#currentResult); |
| 2033 |
}); |
| 2034 |
} |
| 2035 |
this.#client.getQueryCache().notify({ |
| 2036 |
query: this.#currentQuery, |
| 2037 |
type: "observerResultsUpdated" |
| 2038 |
}); |
| 2039 |
}); |
| 2040 |
} |
| 2041 |
}; |
| 2042 |
function shouldLoadOnMount(query, options) { |
| 2043 |
return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === "error" && options.retryOnMount === false); |
| 2044 |
} |
| 2045 |
function shouldFetchOnMount(query, options) { |
| 2046 |
return shouldLoadOnMount(query, options) || query.state.dataUpdatedAt > 0 && shouldFetchOn(query, options, options.refetchOnMount); |
| 2047 |
} |
| 2048 |
function shouldFetchOn(query, options, field) { |
| 2049 |
if (options.enabled !== false) { |
| 2050 |
const value = typeof field === "function" ? field(query) : field; |
| 2051 |
return value === "always" || value !== false && isStale(query, options); |
| 2052 |
} |
| 2053 |
return false; |
| 2054 |
} |
| 2055 |
function shouldFetchOptionally(query, prevQuery, options, prevOptions) { |
| 2056 |
return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); |
| 2057 |
} |
| 2058 |
function isStale(query, options) { |
| 2059 |
return query.isStaleByTime(options.staleTime); |
| 2060 |
} |
| 2061 |
function shouldAssignObserverCurrentProperties(observer, optimisticResult) { |
| 2062 |
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.shallowEqualObjects)(observer.getCurrentResult(), optimisticResult)) { |
| 2063 |
return true; |
| 2064 |
} |
| 2065 |
return false; |
| 2066 |
} |
| 2067 |
|
| 2068 |
//# sourceMappingURL=queryObserver.js.map |
| 2069 |
|
| 2070 |
/***/ }), |
| 2071 |
|
| 2072 |
/***/ "./node_modules/@tanstack/query-core/build/modern/removable.js": |
| 2073 |
/*!*********************************************************************!*\ |
| 2074 |
!*** ./node_modules/@tanstack/query-core/build/modern/removable.js ***! |
| 2075 |
\*********************************************************************/ |
| 2076 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2077 |
|
| 2078 |
__webpack_require__.r(__webpack_exports__); |
| 2079 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2080 |
/* harmony export */ Removable: function() { return /* binding */ Removable; } |
| 2081 |
/* harmony export */ }); |
| 2082 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 2083 |
// src/removable.ts |
| 2084 |
|
| 2085 |
var Removable = class { |
| 2086 |
#gcTimeout; |
| 2087 |
destroy() { |
| 2088 |
this.clearGcTimeout(); |
| 2089 |
} |
| 2090 |
scheduleGc() { |
| 2091 |
this.clearGcTimeout(); |
| 2092 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.isValidTimeout)(this.gcTime)) { |
| 2093 |
this.#gcTimeout = setTimeout(() => { |
| 2094 |
this.optionalRemove(); |
| 2095 |
}, this.gcTime); |
| 2096 |
} |
| 2097 |
} |
| 2098 |
updateGcTime(newGcTime) { |
| 2099 |
this.gcTime = Math.max( |
| 2100 |
this.gcTime || 0, |
| 2101 |
newGcTime ?? (_utils_js__WEBPACK_IMPORTED_MODULE_0__.isServer ? Infinity : 5 * 60 * 1e3) |
| 2102 |
); |
| 2103 |
} |
| 2104 |
clearGcTimeout() { |
| 2105 |
if (this.#gcTimeout) { |
| 2106 |
clearTimeout(this.#gcTimeout); |
| 2107 |
this.#gcTimeout = void 0; |
| 2108 |
} |
| 2109 |
} |
| 2110 |
}; |
| 2111 |
|
| 2112 |
//# sourceMappingURL=removable.js.map |
| 2113 |
|
| 2114 |
/***/ }), |
| 2115 |
|
| 2116 |
/***/ "./node_modules/@tanstack/query-core/build/modern/retryer.js": |
| 2117 |
/*!*******************************************************************!*\ |
| 2118 |
!*** ./node_modules/@tanstack/query-core/build/modern/retryer.js ***! |
| 2119 |
\*******************************************************************/ |
| 2120 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2121 |
|
| 2122 |
__webpack_require__.r(__webpack_exports__); |
| 2123 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2124 |
/* harmony export */ CancelledError: function() { return /* binding */ CancelledError; }, |
| 2125 |
/* harmony export */ canFetch: function() { return /* binding */ canFetch; }, |
| 2126 |
/* harmony export */ createRetryer: function() { return /* binding */ createRetryer; }, |
| 2127 |
/* harmony export */ isCancelledError: function() { return /* binding */ isCancelledError; } |
| 2128 |
/* harmony export */ }); |
| 2129 |
/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); |
| 2130 |
/* harmony import */ var _onlineManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./onlineManager.js */ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js"); |
| 2131 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 2132 |
// src/retryer.ts |
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
function defaultRetryDelay(failureCount) { |
| 2137 |
return Math.min(1e3 * 2 ** failureCount, 3e4); |
| 2138 |
} |
| 2139 |
function canFetch(networkMode) { |
| 2140 |
return (networkMode ?? "online") === "online" ? _onlineManager_js__WEBPACK_IMPORTED_MODULE_0__.onlineManager.isOnline() : true; |
| 2141 |
} |
| 2142 |
var CancelledError = class { |
| 2143 |
constructor(options) { |
| 2144 |
this.revert = options?.revert; |
| 2145 |
this.silent = options?.silent; |
| 2146 |
} |
| 2147 |
}; |
| 2148 |
function isCancelledError(value) { |
| 2149 |
return value instanceof CancelledError; |
| 2150 |
} |
| 2151 |
function createRetryer(config) { |
| 2152 |
let isRetryCancelled = false; |
| 2153 |
let failureCount = 0; |
| 2154 |
let isResolved = false; |
| 2155 |
let continueFn; |
| 2156 |
let promiseResolve; |
| 2157 |
let promiseReject; |
| 2158 |
const promise = new Promise((outerResolve, outerReject) => { |
| 2159 |
promiseResolve = outerResolve; |
| 2160 |
promiseReject = outerReject; |
| 2161 |
}); |
| 2162 |
const cancel = (cancelOptions) => { |
| 2163 |
if (!isResolved) { |
| 2164 |
reject(new CancelledError(cancelOptions)); |
| 2165 |
config.abort?.(); |
| 2166 |
} |
| 2167 |
}; |
| 2168 |
const cancelRetry = () => { |
| 2169 |
isRetryCancelled = true; |
| 2170 |
}; |
| 2171 |
const continueRetry = () => { |
| 2172 |
isRetryCancelled = false; |
| 2173 |
}; |
| 2174 |
const shouldPause = () => !_focusManager_js__WEBPACK_IMPORTED_MODULE_1__.focusManager.isFocused() || config.networkMode !== "always" && !_onlineManager_js__WEBPACK_IMPORTED_MODULE_0__.onlineManager.isOnline(); |
| 2175 |
const resolve = (value) => { |
| 2176 |
if (!isResolved) { |
| 2177 |
isResolved = true; |
| 2178 |
config.onSuccess?.(value); |
| 2179 |
continueFn?.(); |
| 2180 |
promiseResolve(value); |
| 2181 |
} |
| 2182 |
}; |
| 2183 |
const reject = (value) => { |
| 2184 |
if (!isResolved) { |
| 2185 |
isResolved = true; |
| 2186 |
config.onError?.(value); |
| 2187 |
continueFn?.(); |
| 2188 |
promiseReject(value); |
| 2189 |
} |
| 2190 |
}; |
| 2191 |
const pause = () => { |
| 2192 |
return new Promise((continueResolve) => { |
| 2193 |
continueFn = (value) => { |
| 2194 |
const canContinue = isResolved || !shouldPause(); |
| 2195 |
if (canContinue) { |
| 2196 |
continueResolve(value); |
| 2197 |
} |
| 2198 |
return canContinue; |
| 2199 |
}; |
| 2200 |
config.onPause?.(); |
| 2201 |
}).then(() => { |
| 2202 |
continueFn = void 0; |
| 2203 |
if (!isResolved) { |
| 2204 |
config.onContinue?.(); |
| 2205 |
} |
| 2206 |
}); |
| 2207 |
}; |
| 2208 |
const run = () => { |
| 2209 |
if (isResolved) { |
| 2210 |
return; |
| 2211 |
} |
| 2212 |
let promiseOrValue; |
| 2213 |
try { |
| 2214 |
promiseOrValue = config.fn(); |
| 2215 |
} catch (error) { |
| 2216 |
promiseOrValue = Promise.reject(error); |
| 2217 |
} |
| 2218 |
Promise.resolve(promiseOrValue).then(resolve).catch((error) => { |
| 2219 |
if (isResolved) { |
| 2220 |
return; |
| 2221 |
} |
| 2222 |
const retry = config.retry ?? (_utils_js__WEBPACK_IMPORTED_MODULE_2__.isServer ? 0 : 3); |
| 2223 |
const retryDelay = config.retryDelay ?? defaultRetryDelay; |
| 2224 |
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay; |
| 2225 |
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error); |
| 2226 |
if (isRetryCancelled || !shouldRetry) { |
| 2227 |
reject(error); |
| 2228 |
return; |
| 2229 |
} |
| 2230 |
failureCount++; |
| 2231 |
config.onFail?.(failureCount, error); |
| 2232 |
(0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.sleep)(delay).then(() => { |
| 2233 |
if (shouldPause()) { |
| 2234 |
return pause(); |
| 2235 |
} |
| 2236 |
return; |
| 2237 |
}).then(() => { |
| 2238 |
if (isRetryCancelled) { |
| 2239 |
reject(error); |
| 2240 |
} else { |
| 2241 |
run(); |
| 2242 |
} |
| 2243 |
}); |
| 2244 |
}); |
| 2245 |
}; |
| 2246 |
if (canFetch(config.networkMode)) { |
| 2247 |
run(); |
| 2248 |
} else { |
| 2249 |
pause().then(run); |
| 2250 |
} |
| 2251 |
return { |
| 2252 |
promise, |
| 2253 |
cancel, |
| 2254 |
continue: () => { |
| 2255 |
const didContinue = continueFn?.(); |
| 2256 |
return didContinue ? promise : Promise.resolve(); |
| 2257 |
}, |
| 2258 |
cancelRetry, |
| 2259 |
continueRetry |
| 2260 |
}; |
| 2261 |
} |
| 2262 |
|
| 2263 |
//# sourceMappingURL=retryer.js.map |
| 2264 |
|
| 2265 |
/***/ }), |
| 2266 |
|
| 2267 |
/***/ "./node_modules/@tanstack/query-core/build/modern/subscribable.js": |
| 2268 |
/*!************************************************************************!*\ |
| 2269 |
!*** ./node_modules/@tanstack/query-core/build/modern/subscribable.js ***! |
| 2270 |
\************************************************************************/ |
| 2271 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2272 |
|
| 2273 |
__webpack_require__.r(__webpack_exports__); |
| 2274 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2275 |
/* harmony export */ Subscribable: function() { return /* binding */ Subscribable; } |
| 2276 |
/* harmony export */ }); |
| 2277 |
// src/subscribable.ts |
| 2278 |
var Subscribable = class { |
| 2279 |
constructor() { |
| 2280 |
this.listeners = /* @__PURE__ */ new Set(); |
| 2281 |
this.subscribe = this.subscribe.bind(this); |
| 2282 |
} |
| 2283 |
subscribe(listener) { |
| 2284 |
this.listeners.add(listener); |
| 2285 |
this.onSubscribe(); |
| 2286 |
return () => { |
| 2287 |
this.listeners.delete(listener); |
| 2288 |
this.onUnsubscribe(); |
| 2289 |
}; |
| 2290 |
} |
| 2291 |
hasListeners() { |
| 2292 |
return this.listeners.size > 0; |
| 2293 |
} |
| 2294 |
onSubscribe() { |
| 2295 |
} |
| 2296 |
onUnsubscribe() { |
| 2297 |
} |
| 2298 |
}; |
| 2299 |
|
| 2300 |
//# sourceMappingURL=subscribable.js.map |
| 2301 |
|
| 2302 |
/***/ }), |
| 2303 |
|
| 2304 |
/***/ "./node_modules/@tanstack/query-core/build/modern/utils.js": |
| 2305 |
/*!*****************************************************************!*\ |
| 2306 |
!*** ./node_modules/@tanstack/query-core/build/modern/utils.js ***! |
| 2307 |
\*****************************************************************/ |
| 2308 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2309 |
|
| 2310 |
__webpack_require__.r(__webpack_exports__); |
| 2311 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2312 |
/* harmony export */ addToEnd: function() { return /* binding */ addToEnd; }, |
| 2313 |
/* harmony export */ addToStart: function() { return /* binding */ addToStart; }, |
| 2314 |
/* harmony export */ functionalUpdate: function() { return /* binding */ functionalUpdate; }, |
| 2315 |
/* harmony export */ hashKey: function() { return /* binding */ hashKey; }, |
| 2316 |
/* harmony export */ hashQueryKeyByOptions: function() { return /* binding */ hashQueryKeyByOptions; }, |
| 2317 |
/* harmony export */ isPlainArray: function() { return /* binding */ isPlainArray; }, |
| 2318 |
/* harmony export */ isPlainObject: function() { return /* binding */ isPlainObject; }, |
| 2319 |
/* harmony export */ isServer: function() { return /* binding */ isServer; }, |
| 2320 |
/* harmony export */ isValidTimeout: function() { return /* binding */ isValidTimeout; }, |
| 2321 |
/* harmony export */ keepPreviousData: function() { return /* binding */ keepPreviousData; }, |
| 2322 |
/* harmony export */ matchMutation: function() { return /* binding */ matchMutation; }, |
| 2323 |
/* harmony export */ matchQuery: function() { return /* binding */ matchQuery; }, |
| 2324 |
/* harmony export */ noop: function() { return /* binding */ noop; }, |
| 2325 |
/* harmony export */ partialMatchKey: function() { return /* binding */ partialMatchKey; }, |
| 2326 |
/* harmony export */ replaceData: function() { return /* binding */ replaceData; }, |
| 2327 |
/* harmony export */ replaceEqualDeep: function() { return /* binding */ replaceEqualDeep; }, |
| 2328 |
/* harmony export */ scheduleMicrotask: function() { return /* binding */ scheduleMicrotask; }, |
| 2329 |
/* harmony export */ shallowEqualObjects: function() { return /* binding */ shallowEqualObjects; }, |
| 2330 |
/* harmony export */ sleep: function() { return /* binding */ sleep; }, |
| 2331 |
/* harmony export */ timeUntilStale: function() { return /* binding */ timeUntilStale; } |
| 2332 |
/* harmony export */ }); |
| 2333 |
// src/utils.ts |
| 2334 |
var isServer = typeof window === "undefined" || "Deno" in window; |
| 2335 |
function noop() { |
| 2336 |
return void 0; |
| 2337 |
} |
| 2338 |
function functionalUpdate(updater, input) { |
| 2339 |
return typeof updater === "function" ? updater(input) : updater; |
| 2340 |
} |
| 2341 |
function isValidTimeout(value) { |
| 2342 |
return typeof value === "number" && value >= 0 && value !== Infinity; |
| 2343 |
} |
| 2344 |
function timeUntilStale(updatedAt, staleTime) { |
| 2345 |
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); |
| 2346 |
} |
| 2347 |
function matchQuery(filters, query) { |
| 2348 |
const { |
| 2349 |
type = "all", |
| 2350 |
exact, |
| 2351 |
fetchStatus, |
| 2352 |
predicate, |
| 2353 |
queryKey, |
| 2354 |
stale |
| 2355 |
} = filters; |
| 2356 |
if (queryKey) { |
| 2357 |
if (exact) { |
| 2358 |
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) { |
| 2359 |
return false; |
| 2360 |
} |
| 2361 |
} else if (!partialMatchKey(query.queryKey, queryKey)) { |
| 2362 |
return false; |
| 2363 |
} |
| 2364 |
} |
| 2365 |
if (type !== "all") { |
| 2366 |
const isActive = query.isActive(); |
| 2367 |
if (type === "active" && !isActive) { |
| 2368 |
return false; |
| 2369 |
} |
| 2370 |
if (type === "inactive" && isActive) { |
| 2371 |
return false; |
| 2372 |
} |
| 2373 |
} |
| 2374 |
if (typeof stale === "boolean" && query.isStale() !== stale) { |
| 2375 |
return false; |
| 2376 |
} |
| 2377 |
if (typeof fetchStatus !== "undefined" && fetchStatus !== query.state.fetchStatus) { |
| 2378 |
return false; |
| 2379 |
} |
| 2380 |
if (predicate && !predicate(query)) { |
| 2381 |
return false; |
| 2382 |
} |
| 2383 |
return true; |
| 2384 |
} |
| 2385 |
function matchMutation(filters, mutation) { |
| 2386 |
const { exact, status, predicate, mutationKey } = filters; |
| 2387 |
if (mutationKey) { |
| 2388 |
if (!mutation.options.mutationKey) { |
| 2389 |
return false; |
| 2390 |
} |
| 2391 |
if (exact) { |
| 2392 |
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) { |
| 2393 |
return false; |
| 2394 |
} |
| 2395 |
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) { |
| 2396 |
return false; |
| 2397 |
} |
| 2398 |
} |
| 2399 |
if (status && mutation.state.status !== status) { |
| 2400 |
return false; |
| 2401 |
} |
| 2402 |
if (predicate && !predicate(mutation)) { |
| 2403 |
return false; |
| 2404 |
} |
| 2405 |
return true; |
| 2406 |
} |
| 2407 |
function hashQueryKeyByOptions(queryKey, options) { |
| 2408 |
const hashFn = options?.queryKeyHashFn || hashKey; |
| 2409 |
return hashFn(queryKey); |
| 2410 |
} |
| 2411 |
function hashKey(queryKey) { |
| 2412 |
return JSON.stringify( |
| 2413 |
queryKey, |
| 2414 |
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => { |
| 2415 |
result[key] = val[key]; |
| 2416 |
return result; |
| 2417 |
}, {}) : val |
| 2418 |
); |
| 2419 |
} |
| 2420 |
function partialMatchKey(a, b) { |
| 2421 |
if (a === b) { |
| 2422 |
return true; |
| 2423 |
} |
| 2424 |
if (typeof a !== typeof b) { |
| 2425 |
return false; |
| 2426 |
} |
| 2427 |
if (a && b && typeof a === "object" && typeof b === "object") { |
| 2428 |
return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key])); |
| 2429 |
} |
| 2430 |
return false; |
| 2431 |
} |
| 2432 |
function replaceEqualDeep(a, b) { |
| 2433 |
if (a === b) { |
| 2434 |
return a; |
| 2435 |
} |
| 2436 |
const array = isPlainArray(a) && isPlainArray(b); |
| 2437 |
if (array || isPlainObject(a) && isPlainObject(b)) { |
| 2438 |
const aSize = array ? a.length : Object.keys(a).length; |
| 2439 |
const bItems = array ? b : Object.keys(b); |
| 2440 |
const bSize = bItems.length; |
| 2441 |
const copy = array ? [] : {}; |
| 2442 |
let equalItems = 0; |
| 2443 |
for (let i = 0; i < bSize; i++) { |
| 2444 |
const key = array ? i : bItems[i]; |
| 2445 |
copy[key] = replaceEqualDeep(a[key], b[key]); |
| 2446 |
if (copy[key] === a[key]) { |
| 2447 |
equalItems++; |
| 2448 |
} |
| 2449 |
} |
| 2450 |
return aSize === bSize && equalItems === aSize ? a : copy; |
| 2451 |
} |
| 2452 |
return b; |
| 2453 |
} |
| 2454 |
function shallowEqualObjects(a, b) { |
| 2455 |
if (a && !b || b && !a) { |
| 2456 |
return false; |
| 2457 |
} |
| 2458 |
for (const key in a) { |
| 2459 |
if (a[key] !== b[key]) { |
| 2460 |
return false; |
| 2461 |
} |
| 2462 |
} |
| 2463 |
return true; |
| 2464 |
} |
| 2465 |
function isPlainArray(value) { |
| 2466 |
return Array.isArray(value) && value.length === Object.keys(value).length; |
| 2467 |
} |
| 2468 |
function isPlainObject(o) { |
| 2469 |
if (!hasObjectPrototype(o)) { |
| 2470 |
return false; |
| 2471 |
} |
| 2472 |
const ctor = o.constructor; |
| 2473 |
if (typeof ctor === "undefined") { |
| 2474 |
return true; |
| 2475 |
} |
| 2476 |
const prot = ctor.prototype; |
| 2477 |
if (!hasObjectPrototype(prot)) { |
| 2478 |
return false; |
| 2479 |
} |
| 2480 |
if (!prot.hasOwnProperty("isPrototypeOf")) { |
| 2481 |
return false; |
| 2482 |
} |
| 2483 |
return true; |
| 2484 |
} |
| 2485 |
function hasObjectPrototype(o) { |
| 2486 |
return Object.prototype.toString.call(o) === "[object Object]"; |
| 2487 |
} |
| 2488 |
function sleep(timeout) { |
| 2489 |
return new Promise((resolve) => { |
| 2490 |
setTimeout(resolve, timeout); |
| 2491 |
}); |
| 2492 |
} |
| 2493 |
function scheduleMicrotask(callback) { |
| 2494 |
sleep(0).then(callback); |
| 2495 |
} |
| 2496 |
function replaceData(prevData, data, options) { |
| 2497 |
if (typeof options.structuralSharing === "function") { |
| 2498 |
return options.structuralSharing(prevData, data); |
| 2499 |
} else if (options.structuralSharing !== false) { |
| 2500 |
return replaceEqualDeep(prevData, data); |
| 2501 |
} |
| 2502 |
return data; |
| 2503 |
} |
| 2504 |
function keepPreviousData(previousData) { |
| 2505 |
return previousData; |
| 2506 |
} |
| 2507 |
function addToEnd(items, item, max = 0) { |
| 2508 |
const newItems = [...items, item]; |
| 2509 |
return max && newItems.length > max ? newItems.slice(1) : newItems; |
| 2510 |
} |
| 2511 |
function addToStart(items, item, max = 0) { |
| 2512 |
const newItems = [item, ...items]; |
| 2513 |
return max && newItems.length > max ? newItems.slice(0, -1) : newItems; |
| 2514 |
} |
| 2515 |
|
| 2516 |
//# sourceMappingURL=utils.js.map |
| 2517 |
|
| 2518 |
/***/ }), |
| 2519 |
|
| 2520 |
/***/ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js": |
| 2521 |
/*!********************************************************************************!*\ |
| 2522 |
!*** ./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js ***! |
| 2523 |
\********************************************************************************/ |
| 2524 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2525 |
|
| 2526 |
__webpack_require__.r(__webpack_exports__); |
| 2527 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2528 |
/* harmony export */ QueryClientContext: function() { return /* binding */ QueryClientContext; }, |
| 2529 |
/* harmony export */ QueryClientProvider: function() { return /* binding */ QueryClientProvider; }, |
| 2530 |
/* harmony export */ useQueryClient: function() { return /* binding */ useQueryClient; } |
| 2531 |
/* harmony export */ }); |
| 2532 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 2533 |
"use client"; |
| 2534 |
|
| 2535 |
// src/QueryClientProvider.tsx |
| 2536 |
|
| 2537 |
var QueryClientContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext( |
| 2538 |
void 0 |
| 2539 |
); |
| 2540 |
var useQueryClient = (queryClient) => { |
| 2541 |
const client = react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryClientContext); |
| 2542 |
if (queryClient) { |
| 2543 |
return queryClient; |
| 2544 |
} |
| 2545 |
if (!client) { |
| 2546 |
throw new Error("No QueryClient set, use QueryClientProvider to set one"); |
| 2547 |
} |
| 2548 |
return client; |
| 2549 |
}; |
| 2550 |
var QueryClientProvider = ({ |
| 2551 |
client, |
| 2552 |
children |
| 2553 |
}) => { |
| 2554 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 2555 |
client.mount(); |
| 2556 |
return () => { |
| 2557 |
client.unmount(); |
| 2558 |
}; |
| 2559 |
}, [client]); |
| 2560 |
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(QueryClientContext.Provider, { value: client }, children); |
| 2561 |
}; |
| 2562 |
|
| 2563 |
//# sourceMappingURL=QueryClientProvider.js.map |
| 2564 |
|
| 2565 |
/***/ }), |
| 2566 |
|
| 2567 |
/***/ "./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js": |
| 2568 |
/*!************************************************************************************!*\ |
| 2569 |
!*** ./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js ***! |
| 2570 |
\************************************************************************************/ |
| 2571 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2572 |
|
| 2573 |
__webpack_require__.r(__webpack_exports__); |
| 2574 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2575 |
/* harmony export */ QueryErrorResetBoundary: function() { return /* binding */ QueryErrorResetBoundary; }, |
| 2576 |
/* harmony export */ useQueryErrorResetBoundary: function() { return /* binding */ useQueryErrorResetBoundary; } |
| 2577 |
/* harmony export */ }); |
| 2578 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 2579 |
"use client"; |
| 2580 |
|
| 2581 |
// src/QueryErrorResetBoundary.tsx |
| 2582 |
|
| 2583 |
function createValue() { |
| 2584 |
let isReset = false; |
| 2585 |
return { |
| 2586 |
clearReset: () => { |
| 2587 |
isReset = false; |
| 2588 |
}, |
| 2589 |
reset: () => { |
| 2590 |
isReset = true; |
| 2591 |
}, |
| 2592 |
isReset: () => { |
| 2593 |
return isReset; |
| 2594 |
} |
| 2595 |
}; |
| 2596 |
} |
| 2597 |
var QueryErrorResetBoundaryContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(createValue()); |
| 2598 |
var useQueryErrorResetBoundary = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryErrorResetBoundaryContext); |
| 2599 |
var QueryErrorResetBoundary = ({ |
| 2600 |
children |
| 2601 |
}) => { |
| 2602 |
const [value] = react__WEBPACK_IMPORTED_MODULE_0__.useState(() => createValue()); |
| 2603 |
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(QueryErrorResetBoundaryContext.Provider, { value }, typeof children === "function" ? children(value) : children); |
| 2604 |
}; |
| 2605 |
|
| 2606 |
//# sourceMappingURL=QueryErrorResetBoundary.js.map |
| 2607 |
|
| 2608 |
/***/ }), |
| 2609 |
|
| 2610 |
/***/ "./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js": |
| 2611 |
/*!*******************************************************************************!*\ |
| 2612 |
!*** ./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js ***! |
| 2613 |
\*******************************************************************************/ |
| 2614 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2615 |
|
| 2616 |
__webpack_require__.r(__webpack_exports__); |
| 2617 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2618 |
/* harmony export */ ensurePreventErrorBoundaryRetry: function() { return /* binding */ ensurePreventErrorBoundaryRetry; }, |
| 2619 |
/* harmony export */ getHasError: function() { return /* binding */ getHasError; }, |
| 2620 |
/* harmony export */ useClearResetErrorBoundary: function() { return /* binding */ useClearResetErrorBoundary; } |
| 2621 |
/* harmony export */ }); |
| 2622 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 2623 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/react-query/build/modern/utils.js"); |
| 2624 |
"use client"; |
| 2625 |
|
| 2626 |
// src/errorBoundaryUtils.ts |
| 2627 |
|
| 2628 |
|
| 2629 |
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => { |
| 2630 |
if (options.suspense || options.throwOnError) { |
| 2631 |
if (!errorResetBoundary.isReset()) { |
| 2632 |
options.retryOnMount = false; |
| 2633 |
} |
| 2634 |
} |
| 2635 |
}; |
| 2636 |
var useClearResetErrorBoundary = (errorResetBoundary) => { |
| 2637 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 2638 |
errorResetBoundary.clearReset(); |
| 2639 |
}, [errorResetBoundary]); |
| 2640 |
}; |
| 2641 |
var getHasError = ({ |
| 2642 |
result, |
| 2643 |
errorResetBoundary, |
| 2644 |
throwOnError, |
| 2645 |
query |
| 2646 |
}) => { |
| 2647 |
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.shouldThrowError)(throwOnError, [result.error, query]); |
| 2648 |
}; |
| 2649 |
|
| 2650 |
//# sourceMappingURL=errorBoundaryUtils.js.map |
| 2651 |
|
| 2652 |
/***/ }), |
| 2653 |
|
| 2654 |
/***/ "./node_modules/@tanstack/react-query/build/modern/isRestoring.js": |
| 2655 |
/*!************************************************************************!*\ |
| 2656 |
!*** ./node_modules/@tanstack/react-query/build/modern/isRestoring.js ***! |
| 2657 |
\************************************************************************/ |
| 2658 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2659 |
|
| 2660 |
__webpack_require__.r(__webpack_exports__); |
| 2661 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2662 |
/* harmony export */ IsRestoringProvider: function() { return /* binding */ IsRestoringProvider; }, |
| 2663 |
/* harmony export */ useIsRestoring: function() { return /* binding */ useIsRestoring; } |
| 2664 |
/* harmony export */ }); |
| 2665 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 2666 |
"use client"; |
| 2667 |
|
| 2668 |
// src/isRestoring.ts |
| 2669 |
|
| 2670 |
var IsRestoringContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(false); |
| 2671 |
var useIsRestoring = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(IsRestoringContext); |
| 2672 |
var IsRestoringProvider = IsRestoringContext.Provider; |
| 2673 |
|
| 2674 |
//# sourceMappingURL=isRestoring.js.map |
| 2675 |
|
| 2676 |
/***/ }), |
| 2677 |
|
| 2678 |
/***/ "./node_modules/@tanstack/react-query/build/modern/suspense.js": |
| 2679 |
/*!*********************************************************************!*\ |
| 2680 |
!*** ./node_modules/@tanstack/react-query/build/modern/suspense.js ***! |
| 2681 |
\*********************************************************************/ |
| 2682 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2683 |
|
| 2684 |
__webpack_require__.r(__webpack_exports__); |
| 2685 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2686 |
/* harmony export */ defaultThrowOnError: function() { return /* binding */ defaultThrowOnError; }, |
| 2687 |
/* harmony export */ ensureStaleTime: function() { return /* binding */ ensureStaleTime; }, |
| 2688 |
/* harmony export */ fetchOptimistic: function() { return /* binding */ fetchOptimistic; }, |
| 2689 |
/* harmony export */ shouldSuspend: function() { return /* binding */ shouldSuspend; }, |
| 2690 |
/* harmony export */ willFetch: function() { return /* binding */ willFetch; } |
| 2691 |
/* harmony export */ }); |
| 2692 |
// src/suspense.ts |
| 2693 |
var defaultThrowOnError = (_error, query) => typeof query.state.data === "undefined"; |
| 2694 |
var ensureStaleTime = (defaultedOptions) => { |
| 2695 |
if (defaultedOptions.suspense) { |
| 2696 |
if (typeof defaultedOptions.staleTime !== "number") { |
| 2697 |
defaultedOptions.staleTime = 1e3; |
| 2698 |
} |
| 2699 |
} |
| 2700 |
}; |
| 2701 |
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring; |
| 2702 |
var shouldSuspend = (defaultedOptions, result, isRestoring) => defaultedOptions?.suspense && willFetch(result, isRestoring); |
| 2703 |
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => { |
| 2704 |
errorResetBoundary.clearReset(); |
| 2705 |
}); |
| 2706 |
|
| 2707 |
//# sourceMappingURL=suspense.js.map |
| 2708 |
|
| 2709 |
/***/ }), |
| 2710 |
|
| 2711 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js": |
| 2712 |
/*!*************************************************************************!*\ |
| 2713 |
!*** ./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js ***! |
| 2714 |
\*************************************************************************/ |
| 2715 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2716 |
|
| 2717 |
__webpack_require__.r(__webpack_exports__); |
| 2718 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2719 |
/* harmony export */ useBaseQuery: function() { return /* binding */ useBaseQuery; } |
| 2720 |
/* harmony export */ }); |
| 2721 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 2722 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 2723 |
/* harmony import */ var _QueryErrorResetBoundary_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QueryErrorResetBoundary.js */ "./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js"); |
| 2724 |
/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 2725 |
/* harmony import */ var _isRestoring_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./isRestoring.js */ "./node_modules/@tanstack/react-query/build/modern/isRestoring.js"); |
| 2726 |
/* harmony import */ var _errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errorBoundaryUtils.js */ "./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js"); |
| 2727 |
/* harmony import */ var _suspense_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./suspense.js */ "./node_modules/@tanstack/react-query/build/modern/suspense.js"); |
| 2728 |
"use client"; |
| 2729 |
|
| 2730 |
// src/useBaseQuery.ts |
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
function useBaseQuery(options, Observer, queryClient) { |
| 2739 |
if (true) { |
| 2740 |
if (typeof options !== "object" || Array.isArray(options)) { |
| 2741 |
throw new Error( |
| 2742 |
'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' |
| 2743 |
); |
| 2744 |
} |
| 2745 |
} |
| 2746 |
const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_1__.useQueryClient)(queryClient); |
| 2747 |
const isRestoring = (0,_isRestoring_js__WEBPACK_IMPORTED_MODULE_2__.useIsRestoring)(); |
| 2748 |
const errorResetBoundary = (0,_QueryErrorResetBoundary_js__WEBPACK_IMPORTED_MODULE_3__.useQueryErrorResetBoundary)(); |
| 2749 |
const defaultedOptions = client.defaultQueryOptions(options); |
| 2750 |
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic"; |
| 2751 |
(0,_suspense_js__WEBPACK_IMPORTED_MODULE_4__.ensureStaleTime)(defaultedOptions); |
| 2752 |
(0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.ensurePreventErrorBoundaryRetry)(defaultedOptions, errorResetBoundary); |
| 2753 |
(0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.useClearResetErrorBoundary)(errorResetBoundary); |
| 2754 |
const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState( |
| 2755 |
() => new Observer( |
| 2756 |
client, |
| 2757 |
defaultedOptions |
| 2758 |
) |
| 2759 |
); |
| 2760 |
const result = observer.getOptimisticResult(defaultedOptions); |
| 2761 |
react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( |
| 2762 |
react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 2763 |
(onStoreChange) => { |
| 2764 |
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_6__.notifyManager.batchCalls(onStoreChange)); |
| 2765 |
observer.updateResult(); |
| 2766 |
return unsubscribe; |
| 2767 |
}, |
| 2768 |
[observer, isRestoring] |
| 2769 |
), |
| 2770 |
() => observer.getCurrentResult(), |
| 2771 |
() => observer.getCurrentResult() |
| 2772 |
); |
| 2773 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 2774 |
observer.setOptions(defaultedOptions, { listeners: false }); |
| 2775 |
}, [defaultedOptions, observer]); |
| 2776 |
if ((0,_suspense_js__WEBPACK_IMPORTED_MODULE_4__.shouldSuspend)(defaultedOptions, result, isRestoring)) { |
| 2777 |
throw (0,_suspense_js__WEBPACK_IMPORTED_MODULE_4__.fetchOptimistic)(defaultedOptions, observer, errorResetBoundary); |
| 2778 |
} |
| 2779 |
if ((0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.getHasError)({ |
| 2780 |
result, |
| 2781 |
errorResetBoundary, |
| 2782 |
throwOnError: defaultedOptions.throwOnError, |
| 2783 |
query: observer.getCurrentQuery() |
| 2784 |
})) { |
| 2785 |
throw result.error; |
| 2786 |
} |
| 2787 |
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result; |
| 2788 |
} |
| 2789 |
|
| 2790 |
//# sourceMappingURL=useBaseQuery.js.map |
| 2791 |
|
| 2792 |
/***/ }), |
| 2793 |
|
| 2794 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useMutation.js": |
| 2795 |
/*!************************************************************************!*\ |
| 2796 |
!*** ./node_modules/@tanstack/react-query/build/modern/useMutation.js ***! |
| 2797 |
\************************************************************************/ |
| 2798 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2799 |
|
| 2800 |
__webpack_require__.r(__webpack_exports__); |
| 2801 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2802 |
/* harmony export */ useMutation: function() { return /* binding */ useMutation; } |
| 2803 |
/* harmony export */ }); |
| 2804 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 2805 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/mutationObserver.js"); |
| 2806 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 2807 |
/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 2808 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/react-query/build/modern/utils.js"); |
| 2809 |
"use client"; |
| 2810 |
|
| 2811 |
// src/useMutation.ts |
| 2812 |
|
| 2813 |
|
| 2814 |
|
| 2815 |
|
| 2816 |
function useMutation(options, queryClient) { |
| 2817 |
const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_1__.useQueryClient)(queryClient); |
| 2818 |
const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState( |
| 2819 |
() => new _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.MutationObserver( |
| 2820 |
client, |
| 2821 |
options |
| 2822 |
) |
| 2823 |
); |
| 2824 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 2825 |
observer.setOptions(options); |
| 2826 |
}, [observer, options]); |
| 2827 |
const result = react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( |
| 2828 |
react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 2829 |
(onStoreChange) => observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__.notifyManager.batchCalls(onStoreChange)), |
| 2830 |
[observer] |
| 2831 |
), |
| 2832 |
() => observer.getCurrentResult(), |
| 2833 |
() => observer.getCurrentResult() |
| 2834 |
); |
| 2835 |
const mutate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 2836 |
(variables, mutateOptions) => { |
| 2837 |
observer.mutate(variables, mutateOptions).catch(noop); |
| 2838 |
}, |
| 2839 |
[observer] |
| 2840 |
); |
| 2841 |
if (result.error && (0,_utils_js__WEBPACK_IMPORTED_MODULE_4__.shouldThrowError)(observer.options.throwOnError, [result.error])) { |
| 2842 |
throw result.error; |
| 2843 |
} |
| 2844 |
return { ...result, mutate, mutateAsync: result.mutate }; |
| 2845 |
} |
| 2846 |
function noop() { |
| 2847 |
} |
| 2848 |
|
| 2849 |
//# sourceMappingURL=useMutation.js.map |
| 2850 |
|
| 2851 |
/***/ }), |
| 2852 |
|
| 2853 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useQuery.js": |
| 2854 |
/*!*********************************************************************!*\ |
| 2855 |
!*** ./node_modules/@tanstack/react-query/build/modern/useQuery.js ***! |
| 2856 |
\*********************************************************************/ |
| 2857 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2858 |
|
| 2859 |
__webpack_require__.r(__webpack_exports__); |
| 2860 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2861 |
/* harmony export */ useQuery: function() { return /* binding */ useQuery; } |
| 2862 |
/* harmony export */ }); |
| 2863 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js"); |
| 2864 |
/* harmony import */ var _useBaseQuery_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./useBaseQuery.js */ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"); |
| 2865 |
"use client"; |
| 2866 |
|
| 2867 |
// src/useQuery.ts |
| 2868 |
|
| 2869 |
|
| 2870 |
function useQuery(options, queryClient) { |
| 2871 |
return (0,_useBaseQuery_js__WEBPACK_IMPORTED_MODULE_0__.useBaseQuery)(options, _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.QueryObserver, queryClient); |
| 2872 |
} |
| 2873 |
|
| 2874 |
//# sourceMappingURL=useQuery.js.map |
| 2875 |
|
| 2876 |
/***/ }), |
| 2877 |
|
| 2878 |
/***/ "./node_modules/@tanstack/react-query/build/modern/utils.js": |
| 2879 |
/*!******************************************************************!*\ |
| 2880 |
!*** ./node_modules/@tanstack/react-query/build/modern/utils.js ***! |
| 2881 |
\******************************************************************/ |
| 2882 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2883 |
|
| 2884 |
__webpack_require__.r(__webpack_exports__); |
| 2885 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2886 |
/* harmony export */ shouldThrowError: function() { return /* binding */ shouldThrowError; } |
| 2887 |
/* harmony export */ }); |
| 2888 |
// src/utils.ts |
| 2889 |
function shouldThrowError(throwError, params) { |
| 2890 |
if (typeof throwError === "function") { |
| 2891 |
return throwError(...params); |
| 2892 |
} |
| 2893 |
return !!throwError; |
| 2894 |
} |
| 2895 |
|
| 2896 |
//# sourceMappingURL=utils.js.map |
| 2897 |
|
| 2898 |
/***/ }) |
| 2899 |
|
| 2900 |
/******/ }); |
| 2901 |
/************************************************************************/ |
| 2902 |
/******/ // The module cache |
| 2903 |
/******/ var __webpack_module_cache__ = {}; |
| 2904 |
/******/ |
| 2905 |
/******/ // The require function |
| 2906 |
/******/ function __webpack_require__(moduleId) { |
| 2907 |
/******/ // Check if module is in cache |
| 2908 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 2909 |
/******/ if (cachedModule !== undefined) { |
| 2910 |
/******/ return cachedModule.exports; |
| 2911 |
/******/ } |
| 2912 |
/******/ // Create a new module (and put it into the cache) |
| 2913 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 2914 |
/******/ // no module.id needed |
| 2915 |
/******/ // no module.loaded needed |
| 2916 |
/******/ exports: {} |
| 2917 |
/******/ }; |
| 2918 |
/******/ |
| 2919 |
/******/ // Execute the module function |
| 2920 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 2921 |
/******/ |
| 2922 |
/******/ // Return the exports of the module |
| 2923 |
/******/ return module.exports; |
| 2924 |
/******/ } |
| 2925 |
/******/ |
| 2926 |
/************************************************************************/ |
| 2927 |
/******/ /* webpack/runtime/define property getters */ |
| 2928 |
/******/ !function() { |
| 2929 |
/******/ // define getter functions for harmony exports |
| 2930 |
/******/ __webpack_require__.d = function(exports, definition) { |
| 2931 |
/******/ for(var key in definition) { |
| 2932 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 2933 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 2934 |
/******/ } |
| 2935 |
/******/ } |
| 2936 |
/******/ }; |
| 2937 |
/******/ }(); |
| 2938 |
/******/ |
| 2939 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 2940 |
/******/ !function() { |
| 2941 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
| 2942 |
/******/ }(); |
| 2943 |
/******/ |
| 2944 |
/******/ /* webpack/runtime/make namespace object */ |
| 2945 |
/******/ !function() { |
| 2946 |
/******/ // define __esModule on exports |
| 2947 |
/******/ __webpack_require__.r = function(exports) { |
| 2948 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 2949 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 2950 |
/******/ } |
| 2951 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 2952 |
/******/ }; |
| 2953 |
/******/ }(); |
| 2954 |
/******/ |
| 2955 |
/************************************************************************/ |
| 2956 |
var __webpack_exports__ = {}; |
| 2957 |
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. |
| 2958 |
!function() { |
| 2959 |
/*!******************************************************!*\ |
| 2960 |
!*** ./node_modules/@elementor/query/dist/index.mjs ***! |
| 2961 |
\******************************************************/ |
| 2962 |
__webpack_require__.r(__webpack_exports__); |
| 2963 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2964 |
/* harmony export */ QueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient; }, |
| 2965 |
/* harmony export */ QueryClientProvider: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__.QueryClientProvider; }, |
| 2966 |
/* harmony export */ createQueryClient: function() { return /* binding */ createQueryClient; }, |
| 2967 |
/* harmony export */ useMutation: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__.useMutation; }, |
| 2968 |
/* harmony export */ useQuery: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__.useQuery; }, |
| 2969 |
/* harmony export */ useQueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__.useQueryClient; } |
| 2970 |
/* harmony export */ }); |
| 2971 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/query-core/build/modern/queryClient.js"); |
| 2972 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 2973 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useMutation.js"); |
| 2974 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useQuery.js"); |
| 2975 |
// src/index.ts |
| 2976 |
|
| 2977 |
|
| 2978 |
function createQueryClient() { |
| 2979 |
return new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient({ |
| 2980 |
defaultOptions: { |
| 2981 |
queries: { |
| 2982 |
refetchOnWindowFocus: false, |
| 2983 |
refetchOnReconnect: false |
| 2984 |
} |
| 2985 |
} |
| 2986 |
}); |
| 2987 |
} |
| 2988 |
|
| 2989 |
//# sourceMappingURL=index.mjs.map |
| 2990 |
}(); |
| 2991 |
(window.elementorV2 = window.elementorV2 || {}).query = __webpack_exports__; |
| 2992 |
/******/ })() |
| 2993 |
; |