| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ var __webpack_modules__ = ({ |
| 4 |
|
| 5 |
/***/ "./node_modules/@tanstack/query-core/build/modern/focusManager.js": |
| 6 |
/*!************************************************************************!*\ |
| 7 |
!*** ./node_modules/@tanstack/query-core/build/modern/focusManager.js ***! |
| 8 |
\************************************************************************/ |
| 9 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 10 |
|
| 11 |
__webpack_require__.r(__webpack_exports__); |
| 12 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 |
/* harmony export */ FocusManager: function() { return /* binding */ FocusManager; }, |
| 14 |
/* harmony export */ focusManager: function() { return /* binding */ focusManager; } |
| 15 |
/* harmony export */ }); |
| 16 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 17 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 18 |
// src/focusManager.ts |
| 19 |
|
| 20 |
|
| 21 |
var FocusManager = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 22 |
#focused; |
| 23 |
#cleanup; |
| 24 |
#setup; |
| 25 |
constructor() { |
| 26 |
super(); |
| 27 |
this.#setup = (onFocus) => { |
| 28 |
if (!_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { |
| 29 |
const listener = () => onFocus(); |
| 30 |
window.addEventListener("visibilitychange", listener, false); |
| 31 |
return () => { |
| 32 |
window.removeEventListener("visibilitychange", listener); |
| 33 |
}; |
| 34 |
} |
| 35 |
return; |
| 36 |
}; |
| 37 |
} |
| 38 |
onSubscribe() { |
| 39 |
if (!this.#cleanup) { |
| 40 |
this.setEventListener(this.#setup); |
| 41 |
} |
| 42 |
} |
| 43 |
onUnsubscribe() { |
| 44 |
if (!this.hasListeners()) { |
| 45 |
this.#cleanup?.(); |
| 46 |
this.#cleanup = void 0; |
| 47 |
} |
| 48 |
} |
| 49 |
setEventListener(setup) { |
| 50 |
this.#setup = setup; |
| 51 |
this.#cleanup?.(); |
| 52 |
this.#cleanup = setup((focused) => { |
| 53 |
if (typeof focused === "boolean") { |
| 54 |
this.setFocused(focused); |
| 55 |
} else { |
| 56 |
this.onFocus(); |
| 57 |
} |
| 58 |
}); |
| 59 |
} |
| 60 |
setFocused(focused) { |
| 61 |
const changed = this.#focused !== focused; |
| 62 |
if (changed) { |
| 63 |
this.#focused = focused; |
| 64 |
this.onFocus(); |
| 65 |
} |
| 66 |
} |
| 67 |
onFocus() { |
| 68 |
const isFocused = this.isFocused(); |
| 69 |
this.listeners.forEach((listener) => { |
| 70 |
listener(isFocused); |
| 71 |
}); |
| 72 |
} |
| 73 |
isFocused() { |
| 74 |
if (typeof this.#focused === "boolean") { |
| 75 |
return this.#focused; |
| 76 |
} |
| 77 |
return globalThis.document?.visibilityState !== "hidden"; |
| 78 |
} |
| 79 |
}; |
| 80 |
var focusManager = new FocusManager(); |
| 81 |
|
| 82 |
//# sourceMappingURL=focusManager.js.map |
| 83 |
|
| 84 |
/***/ }), |
| 85 |
|
| 86 |
/***/ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js": |
| 87 |
/*!*********************************************************************************!*\ |
| 88 |
!*** ./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js ***! |
| 89 |
\*********************************************************************************/ |
| 90 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 91 |
|
| 92 |
__webpack_require__.r(__webpack_exports__); |
| 93 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 94 |
/* harmony export */ hasNextPage: function() { return /* binding */ hasNextPage; }, |
| 95 |
/* harmony export */ hasPreviousPage: function() { return /* binding */ hasPreviousPage; }, |
| 96 |
/* harmony export */ infiniteQueryBehavior: function() { return /* binding */ infiniteQueryBehavior; } |
| 97 |
/* harmony export */ }); |
| 98 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 99 |
// src/infiniteQueryBehavior.ts |
| 100 |
|
| 101 |
function infiniteQueryBehavior(pages) { |
| 102 |
return { |
| 103 |
onFetch: (context, query) => { |
| 104 |
const options = context.options; |
| 105 |
const direction = context.fetchOptions?.meta?.fetchMore?.direction; |
| 106 |
const oldPages = context.state.data?.pages || []; |
| 107 |
const oldPageParams = context.state.data?.pageParams || []; |
| 108 |
let result = { pages: [], pageParams: [] }; |
| 109 |
let currentPage = 0; |
| 110 |
const fetchFn = async () => { |
| 111 |
let cancelled = false; |
| 112 |
const addSignalProperty = (object) => { |
| 113 |
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.addConsumeAwareSignal)( |
| 114 |
object, |
| 115 |
() => context.signal, |
| 116 |
() => cancelled = true |
| 117 |
); |
| 118 |
}; |
| 119 |
const queryFn = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureQueryFn)(context.options, context.fetchOptions); |
| 120 |
const fetchPage = async (data, param, previous) => { |
| 121 |
if (cancelled) { |
| 122 |
return Promise.reject(); |
| 123 |
} |
| 124 |
if (param == null && data.pages.length) { |
| 125 |
return Promise.resolve(data); |
| 126 |
} |
| 127 |
const createQueryFnContext = () => { |
| 128 |
const queryFnContext2 = { |
| 129 |
client: context.client, |
| 130 |
queryKey: context.queryKey, |
| 131 |
pageParam: param, |
| 132 |
direction: previous ? "backward" : "forward", |
| 133 |
meta: context.options.meta |
| 134 |
}; |
| 135 |
addSignalProperty(queryFnContext2); |
| 136 |
return queryFnContext2; |
| 137 |
}; |
| 138 |
const queryFnContext = createQueryFnContext(); |
| 139 |
const page = await queryFn(queryFnContext); |
| 140 |
const { maxPages } = context.options; |
| 141 |
const addTo = previous ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.addToStart : _utils_js__WEBPACK_IMPORTED_MODULE_0__.addToEnd; |
| 142 |
return { |
| 143 |
pages: addTo(data.pages, page, maxPages), |
| 144 |
pageParams: addTo(data.pageParams, param, maxPages) |
| 145 |
}; |
| 146 |
}; |
| 147 |
if (direction && oldPages.length) { |
| 148 |
const previous = direction === "backward"; |
| 149 |
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam; |
| 150 |
const oldData = { |
| 151 |
pages: oldPages, |
| 152 |
pageParams: oldPageParams |
| 153 |
}; |
| 154 |
const param = pageParamFn(options, oldData); |
| 155 |
result = await fetchPage(oldData, param, previous); |
| 156 |
} else { |
| 157 |
const remainingPages = pages ?? oldPages.length; |
| 158 |
do { |
| 159 |
const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result); |
| 160 |
if (currentPage > 0 && param == null) { |
| 161 |
break; |
| 162 |
} |
| 163 |
result = await fetchPage(result, param); |
| 164 |
currentPage++; |
| 165 |
} while (currentPage < remainingPages); |
| 166 |
} |
| 167 |
return result; |
| 168 |
}; |
| 169 |
if (context.options.persister) { |
| 170 |
context.fetchFn = () => { |
| 171 |
return context.options.persister?.( |
| 172 |
fetchFn, |
| 173 |
{ |
| 174 |
client: context.client, |
| 175 |
queryKey: context.queryKey, |
| 176 |
meta: context.options.meta, |
| 177 |
signal: context.signal |
| 178 |
}, |
| 179 |
query |
| 180 |
); |
| 181 |
}; |
| 182 |
} else { |
| 183 |
context.fetchFn = fetchFn; |
| 184 |
} |
| 185 |
} |
| 186 |
}; |
| 187 |
} |
| 188 |
function getNextPageParam(options, { pages, pageParams }) { |
| 189 |
const lastIndex = pages.length - 1; |
| 190 |
return pages.length > 0 ? options.getNextPageParam( |
| 191 |
pages[lastIndex], |
| 192 |
pages, |
| 193 |
pageParams[lastIndex], |
| 194 |
pageParams |
| 195 |
) : void 0; |
| 196 |
} |
| 197 |
function getPreviousPageParam(options, { pages, pageParams }) { |
| 198 |
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0; |
| 199 |
} |
| 200 |
function hasNextPage(options, data) { |
| 201 |
if (!data) return false; |
| 202 |
return getNextPageParam(options, data) != null; |
| 203 |
} |
| 204 |
function hasPreviousPage(options, data) { |
| 205 |
if (!data || !options.getPreviousPageParam) return false; |
| 206 |
return getPreviousPageParam(options, data) != null; |
| 207 |
} |
| 208 |
|
| 209 |
//# sourceMappingURL=infiniteQueryBehavior.js.map |
| 210 |
|
| 211 |
/***/ }), |
| 212 |
|
| 213 |
/***/ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js": |
| 214 |
/*!*********************************************************************************!*\ |
| 215 |
!*** ./node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js ***! |
| 216 |
\*********************************************************************************/ |
| 217 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 218 |
|
| 219 |
__webpack_require__.r(__webpack_exports__); |
| 220 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 221 |
/* harmony export */ InfiniteQueryObserver: function() { return /* binding */ InfiniteQueryObserver; } |
| 222 |
/* harmony export */ }); |
| 223 |
/* harmony import */ var _queryObserver_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./queryObserver.js */ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js"); |
| 224 |
/* harmony import */ var _infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./infiniteQueryBehavior.js */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js"); |
| 225 |
// src/infiniteQueryObserver.ts |
| 226 |
|
| 227 |
|
| 228 |
var InfiniteQueryObserver = class extends _queryObserver_js__WEBPACK_IMPORTED_MODULE_0__.QueryObserver { |
| 229 |
constructor(client, options) { |
| 230 |
super(client, options); |
| 231 |
} |
| 232 |
bindMethods() { |
| 233 |
super.bindMethods(); |
| 234 |
this.fetchNextPage = this.fetchNextPage.bind(this); |
| 235 |
this.fetchPreviousPage = this.fetchPreviousPage.bind(this); |
| 236 |
} |
| 237 |
setOptions(options) { |
| 238 |
super.setOptions({ |
| 239 |
...options, |
| 240 |
behavior: (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.infiniteQueryBehavior)() |
| 241 |
}); |
| 242 |
} |
| 243 |
getOptimisticResult(options) { |
| 244 |
options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.infiniteQueryBehavior)(); |
| 245 |
return super.getOptimisticResult(options); |
| 246 |
} |
| 247 |
fetchNextPage(options) { |
| 248 |
return this.fetch({ |
| 249 |
...options, |
| 250 |
meta: { |
| 251 |
fetchMore: { direction: "forward" } |
| 252 |
} |
| 253 |
}); |
| 254 |
} |
| 255 |
fetchPreviousPage(options) { |
| 256 |
return this.fetch({ |
| 257 |
...options, |
| 258 |
meta: { |
| 259 |
fetchMore: { direction: "backward" } |
| 260 |
} |
| 261 |
}); |
| 262 |
} |
| 263 |
createResult(query, options) { |
| 264 |
const { state } = query; |
| 265 |
const parentResult = super.createResult(query, options); |
| 266 |
const { isFetching, isRefetching, isError, isRefetchError } = parentResult; |
| 267 |
const fetchDirection = state.fetchMeta?.fetchMore?.direction; |
| 268 |
const isFetchNextPageError = isError && fetchDirection === "forward"; |
| 269 |
const isFetchingNextPage = isFetching && fetchDirection === "forward"; |
| 270 |
const isFetchPreviousPageError = isError && fetchDirection === "backward"; |
| 271 |
const isFetchingPreviousPage = isFetching && fetchDirection === "backward"; |
| 272 |
const result = { |
| 273 |
...parentResult, |
| 274 |
fetchNextPage: this.fetchNextPage, |
| 275 |
fetchPreviousPage: this.fetchPreviousPage, |
| 276 |
hasNextPage: (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.hasNextPage)(options, state.data), |
| 277 |
hasPreviousPage: (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_1__.hasPreviousPage)(options, state.data), |
| 278 |
isFetchNextPageError, |
| 279 |
isFetchingNextPage, |
| 280 |
isFetchPreviousPageError, |
| 281 |
isFetchingPreviousPage, |
| 282 |
isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError, |
| 283 |
isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage |
| 284 |
}; |
| 285 |
return result; |
| 286 |
} |
| 287 |
}; |
| 288 |
|
| 289 |
//# sourceMappingURL=infiniteQueryObserver.js.map |
| 290 |
|
| 291 |
/***/ }), |
| 292 |
|
| 293 |
/***/ "./node_modules/@tanstack/query-core/build/modern/mutation.js": |
| 294 |
/*!********************************************************************!*\ |
| 295 |
!*** ./node_modules/@tanstack/query-core/build/modern/mutation.js ***! |
| 296 |
\********************************************************************/ |
| 297 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 298 |
|
| 299 |
__webpack_require__.r(__webpack_exports__); |
| 300 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 301 |
/* harmony export */ Mutation: function() { return /* binding */ Mutation; }, |
| 302 |
/* harmony export */ getDefaultState: function() { return /* binding */ getDefaultState; } |
| 303 |
/* harmony export */ }); |
| 304 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 305 |
/* harmony import */ var _removable_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./removable.js */ "./node_modules/@tanstack/query-core/build/modern/removable.js"); |
| 306 |
/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); |
| 307 |
// src/mutation.ts |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
var Mutation = class extends _removable_js__WEBPACK_IMPORTED_MODULE_1__.Removable { |
| 312 |
#client; |
| 313 |
#observers; |
| 314 |
#mutationCache; |
| 315 |
#retryer; |
| 316 |
constructor(config) { |
| 317 |
super(); |
| 318 |
this.#client = config.client; |
| 319 |
this.mutationId = config.mutationId; |
| 320 |
this.#mutationCache = config.mutationCache; |
| 321 |
this.#observers = []; |
| 322 |
this.state = config.state || getDefaultState(); |
| 323 |
this.setOptions(config.options); |
| 324 |
this.scheduleGc(); |
| 325 |
} |
| 326 |
setOptions(options) { |
| 327 |
this.options = options; |
| 328 |
this.updateGcTime(this.options.gcTime); |
| 329 |
} |
| 330 |
get meta() { |
| 331 |
return this.options.meta; |
| 332 |
} |
| 333 |
addObserver(observer) { |
| 334 |
if (!this.#observers.includes(observer)) { |
| 335 |
this.#observers.push(observer); |
| 336 |
this.clearGcTimeout(); |
| 337 |
this.#mutationCache.notify({ |
| 338 |
type: "observerAdded", |
| 339 |
mutation: this, |
| 340 |
observer |
| 341 |
}); |
| 342 |
} |
| 343 |
} |
| 344 |
removeObserver(observer) { |
| 345 |
this.#observers = this.#observers.filter((x) => x !== observer); |
| 346 |
this.scheduleGc(); |
| 347 |
this.#mutationCache.notify({ |
| 348 |
type: "observerRemoved", |
| 349 |
mutation: this, |
| 350 |
observer |
| 351 |
}); |
| 352 |
} |
| 353 |
optionalRemove() { |
| 354 |
if (!this.#observers.length) { |
| 355 |
if (this.state.status === "pending") { |
| 356 |
this.scheduleGc(); |
| 357 |
} else { |
| 358 |
this.#mutationCache.remove(this); |
| 359 |
} |
| 360 |
} |
| 361 |
} |
| 362 |
continue() { |
| 363 |
return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before |
| 364 |
this.execute(this.state.variables); |
| 365 |
} |
| 366 |
async execute(variables) { |
| 367 |
const onContinue = () => { |
| 368 |
this.#dispatch({ type: "continue" }); |
| 369 |
}; |
| 370 |
const mutationFnContext = { |
| 371 |
client: this.#client, |
| 372 |
meta: this.options.meta, |
| 373 |
mutationKey: this.options.mutationKey |
| 374 |
}; |
| 375 |
this.#retryer = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.createRetryer)({ |
| 376 |
fn: () => { |
| 377 |
if (!this.options.mutationFn) { |
| 378 |
return Promise.reject(new Error("No mutationFn found")); |
| 379 |
} |
| 380 |
return this.options.mutationFn(variables, mutationFnContext); |
| 381 |
}, |
| 382 |
onFail: (failureCount, error) => { |
| 383 |
this.#dispatch({ type: "failed", failureCount, error }); |
| 384 |
}, |
| 385 |
onPause: () => { |
| 386 |
this.#dispatch({ type: "pause" }); |
| 387 |
}, |
| 388 |
onContinue, |
| 389 |
retry: this.options.retry ?? 0, |
| 390 |
retryDelay: this.options.retryDelay, |
| 391 |
networkMode: this.options.networkMode, |
| 392 |
canRun: () => this.#mutationCache.canRun(this) |
| 393 |
}); |
| 394 |
const restored = this.state.status === "pending"; |
| 395 |
const isPaused = !this.#retryer.canStart(); |
| 396 |
try { |
| 397 |
if (restored) { |
| 398 |
onContinue(); |
| 399 |
} else { |
| 400 |
this.#dispatch({ type: "pending", variables, isPaused }); |
| 401 |
await this.#mutationCache.config.onMutate?.( |
| 402 |
variables, |
| 403 |
this, |
| 404 |
mutationFnContext |
| 405 |
); |
| 406 |
const context = await this.options.onMutate?.( |
| 407 |
variables, |
| 408 |
mutationFnContext |
| 409 |
); |
| 410 |
if (context !== this.state.context) { |
| 411 |
this.#dispatch({ |
| 412 |
type: "pending", |
| 413 |
context, |
| 414 |
variables, |
| 415 |
isPaused |
| 416 |
}); |
| 417 |
} |
| 418 |
} |
| 419 |
const data = await this.#retryer.start(); |
| 420 |
await this.#mutationCache.config.onSuccess?.( |
| 421 |
data, |
| 422 |
variables, |
| 423 |
this.state.context, |
| 424 |
this, |
| 425 |
mutationFnContext |
| 426 |
); |
| 427 |
await this.options.onSuccess?.( |
| 428 |
data, |
| 429 |
variables, |
| 430 |
this.state.context, |
| 431 |
mutationFnContext |
| 432 |
); |
| 433 |
await this.#mutationCache.config.onSettled?.( |
| 434 |
data, |
| 435 |
null, |
| 436 |
this.state.variables, |
| 437 |
this.state.context, |
| 438 |
this, |
| 439 |
mutationFnContext |
| 440 |
); |
| 441 |
await this.options.onSettled?.( |
| 442 |
data, |
| 443 |
null, |
| 444 |
variables, |
| 445 |
this.state.context, |
| 446 |
mutationFnContext |
| 447 |
); |
| 448 |
this.#dispatch({ type: "success", data }); |
| 449 |
return data; |
| 450 |
} catch (error) { |
| 451 |
try { |
| 452 |
await this.#mutationCache.config.onError?.( |
| 453 |
error, |
| 454 |
variables, |
| 455 |
this.state.context, |
| 456 |
this, |
| 457 |
mutationFnContext |
| 458 |
); |
| 459 |
await this.options.onError?.( |
| 460 |
error, |
| 461 |
variables, |
| 462 |
this.state.context, |
| 463 |
mutationFnContext |
| 464 |
); |
| 465 |
await this.#mutationCache.config.onSettled?.( |
| 466 |
void 0, |
| 467 |
error, |
| 468 |
this.state.variables, |
| 469 |
this.state.context, |
| 470 |
this, |
| 471 |
mutationFnContext |
| 472 |
); |
| 473 |
await this.options.onSettled?.( |
| 474 |
void 0, |
| 475 |
error, |
| 476 |
variables, |
| 477 |
this.state.context, |
| 478 |
mutationFnContext |
| 479 |
); |
| 480 |
throw error; |
| 481 |
} finally { |
| 482 |
this.#dispatch({ type: "error", error }); |
| 483 |
} |
| 484 |
} finally { |
| 485 |
this.#mutationCache.runNext(this); |
| 486 |
} |
| 487 |
} |
| 488 |
#dispatch(action) { |
| 489 |
const reducer = (state) => { |
| 490 |
switch (action.type) { |
| 491 |
case "failed": |
| 492 |
return { |
| 493 |
...state, |
| 494 |
failureCount: action.failureCount, |
| 495 |
failureReason: action.error |
| 496 |
}; |
| 497 |
case "pause": |
| 498 |
return { |
| 499 |
...state, |
| 500 |
isPaused: true |
| 501 |
}; |
| 502 |
case "continue": |
| 503 |
return { |
| 504 |
...state, |
| 505 |
isPaused: false |
| 506 |
}; |
| 507 |
case "pending": |
| 508 |
return { |
| 509 |
...state, |
| 510 |
context: action.context, |
| 511 |
data: void 0, |
| 512 |
failureCount: 0, |
| 513 |
failureReason: null, |
| 514 |
error: null, |
| 515 |
isPaused: action.isPaused, |
| 516 |
status: "pending", |
| 517 |
variables: action.variables, |
| 518 |
submittedAt: Date.now() |
| 519 |
}; |
| 520 |
case "success": |
| 521 |
return { |
| 522 |
...state, |
| 523 |
data: action.data, |
| 524 |
failureCount: 0, |
| 525 |
failureReason: null, |
| 526 |
error: null, |
| 527 |
status: "success", |
| 528 |
isPaused: false |
| 529 |
}; |
| 530 |
case "error": |
| 531 |
return { |
| 532 |
...state, |
| 533 |
data: void 0, |
| 534 |
error: action.error, |
| 535 |
failureCount: state.failureCount + 1, |
| 536 |
failureReason: action.error, |
| 537 |
isPaused: false, |
| 538 |
status: "error" |
| 539 |
}; |
| 540 |
} |
| 541 |
}; |
| 542 |
this.state = reducer(this.state); |
| 543 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch(() => { |
| 544 |
this.#observers.forEach((observer) => { |
| 545 |
observer.onMutationUpdate(action); |
| 546 |
}); |
| 547 |
this.#mutationCache.notify({ |
| 548 |
mutation: this, |
| 549 |
type: "updated", |
| 550 |
action |
| 551 |
}); |
| 552 |
}); |
| 553 |
} |
| 554 |
}; |
| 555 |
function getDefaultState() { |
| 556 |
return { |
| 557 |
context: void 0, |
| 558 |
data: void 0, |
| 559 |
error: null, |
| 560 |
failureCount: 0, |
| 561 |
failureReason: null, |
| 562 |
isPaused: false, |
| 563 |
status: "idle", |
| 564 |
variables: void 0, |
| 565 |
submittedAt: 0 |
| 566 |
}; |
| 567 |
} |
| 568 |
|
| 569 |
//# sourceMappingURL=mutation.js.map |
| 570 |
|
| 571 |
/***/ }), |
| 572 |
|
| 573 |
/***/ "./node_modules/@tanstack/query-core/build/modern/mutationCache.js": |
| 574 |
/*!*************************************************************************!*\ |
| 575 |
!*** ./node_modules/@tanstack/query-core/build/modern/mutationCache.js ***! |
| 576 |
\*************************************************************************/ |
| 577 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 578 |
|
| 579 |
__webpack_require__.r(__webpack_exports__); |
| 580 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 581 |
/* harmony export */ MutationCache: function() { return /* binding */ MutationCache; } |
| 582 |
/* harmony export */ }); |
| 583 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 584 |
/* harmony import */ var _mutation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mutation.js */ "./node_modules/@tanstack/query-core/build/modern/mutation.js"); |
| 585 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 586 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 587 |
// src/mutationCache.ts |
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
var MutationCache = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_3__.Subscribable { |
| 593 |
constructor(config = {}) { |
| 594 |
super(); |
| 595 |
this.config = config; |
| 596 |
this.#mutations = /* @__PURE__ */ new Set(); |
| 597 |
this.#scopes = /* @__PURE__ */ new Map(); |
| 598 |
this.#mutationId = 0; |
| 599 |
} |
| 600 |
#mutations; |
| 601 |
#scopes; |
| 602 |
#mutationId; |
| 603 |
build(client, options, state) { |
| 604 |
const mutation = new _mutation_js__WEBPACK_IMPORTED_MODULE_1__.Mutation({ |
| 605 |
client, |
| 606 |
mutationCache: this, |
| 607 |
mutationId: ++this.#mutationId, |
| 608 |
options: client.defaultMutationOptions(options), |
| 609 |
state |
| 610 |
}); |
| 611 |
this.add(mutation); |
| 612 |
return mutation; |
| 613 |
} |
| 614 |
add(mutation) { |
| 615 |
this.#mutations.add(mutation); |
| 616 |
const scope = scopeFor(mutation); |
| 617 |
if (typeof scope === "string") { |
| 618 |
const scopedMutations = this.#scopes.get(scope); |
| 619 |
if (scopedMutations) { |
| 620 |
scopedMutations.push(mutation); |
| 621 |
} else { |
| 622 |
this.#scopes.set(scope, [mutation]); |
| 623 |
} |
| 624 |
} |
| 625 |
this.notify({ type: "added", mutation }); |
| 626 |
} |
| 627 |
remove(mutation) { |
| 628 |
if (this.#mutations.delete(mutation)) { |
| 629 |
const scope = scopeFor(mutation); |
| 630 |
if (typeof scope === "string") { |
| 631 |
const scopedMutations = this.#scopes.get(scope); |
| 632 |
if (scopedMutations) { |
| 633 |
if (scopedMutations.length > 1) { |
| 634 |
const index = scopedMutations.indexOf(mutation); |
| 635 |
if (index !== -1) { |
| 636 |
scopedMutations.splice(index, 1); |
| 637 |
} |
| 638 |
} else if (scopedMutations[0] === mutation) { |
| 639 |
this.#scopes.delete(scope); |
| 640 |
} |
| 641 |
} |
| 642 |
} |
| 643 |
} |
| 644 |
this.notify({ type: "removed", mutation }); |
| 645 |
} |
| 646 |
canRun(mutation) { |
| 647 |
const scope = scopeFor(mutation); |
| 648 |
if (typeof scope === "string") { |
| 649 |
const mutationsWithSameScope = this.#scopes.get(scope); |
| 650 |
const firstPendingMutation = mutationsWithSameScope?.find( |
| 651 |
(m) => m.state.status === "pending" |
| 652 |
); |
| 653 |
return !firstPendingMutation || firstPendingMutation === mutation; |
| 654 |
} else { |
| 655 |
return true; |
| 656 |
} |
| 657 |
} |
| 658 |
runNext(mutation) { |
| 659 |
const scope = scopeFor(mutation); |
| 660 |
if (typeof scope === "string") { |
| 661 |
const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused); |
| 662 |
return foundMutation?.continue() ?? Promise.resolve(); |
| 663 |
} else { |
| 664 |
return Promise.resolve(); |
| 665 |
} |
| 666 |
} |
| 667 |
clear() { |
| 668 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch(() => { |
| 669 |
this.#mutations.forEach((mutation) => { |
| 670 |
this.notify({ type: "removed", mutation }); |
| 671 |
}); |
| 672 |
this.#mutations.clear(); |
| 673 |
this.#scopes.clear(); |
| 674 |
}); |
| 675 |
} |
| 676 |
getAll() { |
| 677 |
return Array.from(this.#mutations); |
| 678 |
} |
| 679 |
find(filters) { |
| 680 |
const defaultedFilters = { exact: true, ...filters }; |
| 681 |
return this.getAll().find( |
| 682 |
(mutation) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.matchMutation)(defaultedFilters, mutation) |
| 683 |
); |
| 684 |
} |
| 685 |
findAll(filters = {}) { |
| 686 |
return this.getAll().filter((mutation) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_2__.matchMutation)(filters, mutation)); |
| 687 |
} |
| 688 |
notify(event) { |
| 689 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch(() => { |
| 690 |
this.listeners.forEach((listener) => { |
| 691 |
listener(event); |
| 692 |
}); |
| 693 |
}); |
| 694 |
} |
| 695 |
resumePausedMutations() { |
| 696 |
const pausedMutations = this.getAll().filter((x) => x.state.isPaused); |
| 697 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_0__.notifyManager.batch( |
| 698 |
() => Promise.all( |
| 699 |
pausedMutations.map((mutation) => mutation.continue().catch(_utils_js__WEBPACK_IMPORTED_MODULE_2__.noop)) |
| 700 |
) |
| 701 |
); |
| 702 |
} |
| 703 |
}; |
| 704 |
function scopeFor(mutation) { |
| 705 |
return mutation.options.scope?.id; |
| 706 |
} |
| 707 |
|
| 708 |
//# sourceMappingURL=mutationCache.js.map |
| 709 |
|
| 710 |
/***/ }), |
| 711 |
|
| 712 |
/***/ "./node_modules/@tanstack/query-core/build/modern/mutationObserver.js": |
| 713 |
/*!****************************************************************************!*\ |
| 714 |
!*** ./node_modules/@tanstack/query-core/build/modern/mutationObserver.js ***! |
| 715 |
\****************************************************************************/ |
| 716 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 717 |
|
| 718 |
__webpack_require__.r(__webpack_exports__); |
| 719 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 720 |
/* harmony export */ MutationObserver: function() { return /* binding */ MutationObserver; } |
| 721 |
/* harmony export */ }); |
| 722 |
/* harmony import */ var _mutation_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mutation.js */ "./node_modules/@tanstack/query-core/build/modern/mutation.js"); |
| 723 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 724 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 725 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 726 |
// src/mutationObserver.ts |
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
var MutationObserver = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_2__.Subscribable { |
| 732 |
#client; |
| 733 |
#currentResult = void 0; |
| 734 |
#currentMutation; |
| 735 |
#mutateOptions; |
| 736 |
constructor(client, options) { |
| 737 |
super(); |
| 738 |
this.#client = client; |
| 739 |
this.setOptions(options); |
| 740 |
this.bindMethods(); |
| 741 |
this.#updateResult(); |
| 742 |
} |
| 743 |
bindMethods() { |
| 744 |
this.mutate = this.mutate.bind(this); |
| 745 |
this.reset = this.reset.bind(this); |
| 746 |
} |
| 747 |
setOptions(options) { |
| 748 |
const prevOptions = this.options; |
| 749 |
this.options = this.#client.defaultMutationOptions(options); |
| 750 |
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.shallowEqualObjects)(this.options, prevOptions)) { |
| 751 |
this.#client.getMutationCache().notify({ |
| 752 |
type: "observerOptionsUpdated", |
| 753 |
mutation: this.#currentMutation, |
| 754 |
observer: this |
| 755 |
}); |
| 756 |
} |
| 757 |
if (prevOptions?.mutationKey && this.options.mutationKey && (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.hashKey)(prevOptions.mutationKey) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.hashKey)(this.options.mutationKey)) { |
| 758 |
this.reset(); |
| 759 |
} else if (this.#currentMutation?.state.status === "pending") { |
| 760 |
this.#currentMutation.setOptions(this.options); |
| 761 |
} |
| 762 |
} |
| 763 |
onUnsubscribe() { |
| 764 |
if (!this.hasListeners()) { |
| 765 |
this.#currentMutation?.removeObserver(this); |
| 766 |
} |
| 767 |
} |
| 768 |
onMutationUpdate(action) { |
| 769 |
this.#updateResult(); |
| 770 |
this.#notify(action); |
| 771 |
} |
| 772 |
getCurrentResult() { |
| 773 |
return this.#currentResult; |
| 774 |
} |
| 775 |
reset() { |
| 776 |
this.#currentMutation?.removeObserver(this); |
| 777 |
this.#currentMutation = void 0; |
| 778 |
this.#updateResult(); |
| 779 |
this.#notify(); |
| 780 |
} |
| 781 |
mutate(variables, options) { |
| 782 |
this.#mutateOptions = options; |
| 783 |
this.#currentMutation?.removeObserver(this); |
| 784 |
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options); |
| 785 |
this.#currentMutation.addObserver(this); |
| 786 |
return this.#currentMutation.execute(variables); |
| 787 |
} |
| 788 |
#updateResult() { |
| 789 |
const state = this.#currentMutation?.state ?? (0,_mutation_js__WEBPACK_IMPORTED_MODULE_0__.getDefaultState)(); |
| 790 |
this.#currentResult = { |
| 791 |
...state, |
| 792 |
isPending: state.status === "pending", |
| 793 |
isSuccess: state.status === "success", |
| 794 |
isError: state.status === "error", |
| 795 |
isIdle: state.status === "idle", |
| 796 |
mutate: this.mutate, |
| 797 |
reset: this.reset |
| 798 |
}; |
| 799 |
} |
| 800 |
#notify(action) { |
| 801 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batch(() => { |
| 802 |
if (this.#mutateOptions && this.hasListeners()) { |
| 803 |
const variables = this.#currentResult.variables; |
| 804 |
const onMutateResult = this.#currentResult.context; |
| 805 |
const context = { |
| 806 |
client: this.#client, |
| 807 |
meta: this.options.meta, |
| 808 |
mutationKey: this.options.mutationKey |
| 809 |
}; |
| 810 |
if (action?.type === "success") { |
| 811 |
this.#mutateOptions.onSuccess?.( |
| 812 |
action.data, |
| 813 |
variables, |
| 814 |
onMutateResult, |
| 815 |
context |
| 816 |
); |
| 817 |
this.#mutateOptions.onSettled?.( |
| 818 |
action.data, |
| 819 |
null, |
| 820 |
variables, |
| 821 |
onMutateResult, |
| 822 |
context |
| 823 |
); |
| 824 |
} else if (action?.type === "error") { |
| 825 |
this.#mutateOptions.onError?.( |
| 826 |
action.error, |
| 827 |
variables, |
| 828 |
onMutateResult, |
| 829 |
context |
| 830 |
); |
| 831 |
this.#mutateOptions.onSettled?.( |
| 832 |
void 0, |
| 833 |
action.error, |
| 834 |
variables, |
| 835 |
onMutateResult, |
| 836 |
context |
| 837 |
); |
| 838 |
} |
| 839 |
} |
| 840 |
this.listeners.forEach((listener) => { |
| 841 |
listener(this.#currentResult); |
| 842 |
}); |
| 843 |
}); |
| 844 |
} |
| 845 |
}; |
| 846 |
|
| 847 |
//# sourceMappingURL=mutationObserver.js.map |
| 848 |
|
| 849 |
/***/ }), |
| 850 |
|
| 851 |
/***/ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js": |
| 852 |
/*!*************************************************************************!*\ |
| 853 |
!*** ./node_modules/@tanstack/query-core/build/modern/notifyManager.js ***! |
| 854 |
\*************************************************************************/ |
| 855 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 856 |
|
| 857 |
__webpack_require__.r(__webpack_exports__); |
| 858 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 859 |
/* harmony export */ createNotifyManager: function() { return /* binding */ createNotifyManager; }, |
| 860 |
/* harmony export */ defaultScheduler: function() { return /* binding */ defaultScheduler; }, |
| 861 |
/* harmony export */ notifyManager: function() { return /* binding */ notifyManager; } |
| 862 |
/* harmony export */ }); |
| 863 |
/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); |
| 864 |
// src/notifyManager.ts |
| 865 |
|
| 866 |
var defaultScheduler = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.systemSetTimeoutZero; |
| 867 |
function createNotifyManager() { |
| 868 |
let queue = []; |
| 869 |
let transactions = 0; |
| 870 |
let notifyFn = (callback) => { |
| 871 |
callback(); |
| 872 |
}; |
| 873 |
let batchNotifyFn = (callback) => { |
| 874 |
callback(); |
| 875 |
}; |
| 876 |
let scheduleFn = defaultScheduler; |
| 877 |
const schedule = (callback) => { |
| 878 |
if (transactions) { |
| 879 |
queue.push(callback); |
| 880 |
} else { |
| 881 |
scheduleFn(() => { |
| 882 |
notifyFn(callback); |
| 883 |
}); |
| 884 |
} |
| 885 |
}; |
| 886 |
const flush = () => { |
| 887 |
const originalQueue = queue; |
| 888 |
queue = []; |
| 889 |
if (originalQueue.length) { |
| 890 |
scheduleFn(() => { |
| 891 |
batchNotifyFn(() => { |
| 892 |
originalQueue.forEach((callback) => { |
| 893 |
notifyFn(callback); |
| 894 |
}); |
| 895 |
}); |
| 896 |
}); |
| 897 |
} |
| 898 |
}; |
| 899 |
return { |
| 900 |
batch: (callback) => { |
| 901 |
let result; |
| 902 |
transactions++; |
| 903 |
try { |
| 904 |
result = callback(); |
| 905 |
} finally { |
| 906 |
transactions--; |
| 907 |
if (!transactions) { |
| 908 |
flush(); |
| 909 |
} |
| 910 |
} |
| 911 |
return result; |
| 912 |
}, |
| 913 |
/** |
| 914 |
* All calls to the wrapped function will be batched. |
| 915 |
*/ |
| 916 |
batchCalls: (callback) => { |
| 917 |
return (...args) => { |
| 918 |
schedule(() => { |
| 919 |
callback(...args); |
| 920 |
}); |
| 921 |
}; |
| 922 |
}, |
| 923 |
schedule, |
| 924 |
/** |
| 925 |
* Use this method to set a custom notify function. |
| 926 |
* This can be used to for example wrap notifications with `React.act` while running tests. |
| 927 |
*/ |
| 928 |
setNotifyFunction: (fn) => { |
| 929 |
notifyFn = fn; |
| 930 |
}, |
| 931 |
/** |
| 932 |
* Use this method to set a custom function to batch notifications together into a single tick. |
| 933 |
* By default React Query will use the batch function provided by ReactDOM or React Native. |
| 934 |
*/ |
| 935 |
setBatchNotifyFunction: (fn) => { |
| 936 |
batchNotifyFn = fn; |
| 937 |
}, |
| 938 |
setScheduler: (fn) => { |
| 939 |
scheduleFn = fn; |
| 940 |
} |
| 941 |
}; |
| 942 |
} |
| 943 |
var notifyManager = createNotifyManager(); |
| 944 |
|
| 945 |
//# sourceMappingURL=notifyManager.js.map |
| 946 |
|
| 947 |
/***/ }), |
| 948 |
|
| 949 |
/***/ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js": |
| 950 |
/*!*************************************************************************!*\ |
| 951 |
!*** ./node_modules/@tanstack/query-core/build/modern/onlineManager.js ***! |
| 952 |
\*************************************************************************/ |
| 953 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 954 |
|
| 955 |
__webpack_require__.r(__webpack_exports__); |
| 956 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 957 |
/* harmony export */ OnlineManager: function() { return /* binding */ OnlineManager; }, |
| 958 |
/* harmony export */ onlineManager: function() { return /* binding */ onlineManager; } |
| 959 |
/* harmony export */ }); |
| 960 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 961 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 962 |
// src/onlineManager.ts |
| 963 |
|
| 964 |
|
| 965 |
var OnlineManager = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_0__.Subscribable { |
| 966 |
#online = true; |
| 967 |
#cleanup; |
| 968 |
#setup; |
| 969 |
constructor() { |
| 970 |
super(); |
| 971 |
this.#setup = (onOnline) => { |
| 972 |
if (!_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer && window.addEventListener) { |
| 973 |
const onlineListener = () => onOnline(true); |
| 974 |
const offlineListener = () => onOnline(false); |
| 975 |
window.addEventListener("online", onlineListener, false); |
| 976 |
window.addEventListener("offline", offlineListener, false); |
| 977 |
return () => { |
| 978 |
window.removeEventListener("online", onlineListener); |
| 979 |
window.removeEventListener("offline", offlineListener); |
| 980 |
}; |
| 981 |
} |
| 982 |
return; |
| 983 |
}; |
| 984 |
} |
| 985 |
onSubscribe() { |
| 986 |
if (!this.#cleanup) { |
| 987 |
this.setEventListener(this.#setup); |
| 988 |
} |
| 989 |
} |
| 990 |
onUnsubscribe() { |
| 991 |
if (!this.hasListeners()) { |
| 992 |
this.#cleanup?.(); |
| 993 |
this.#cleanup = void 0; |
| 994 |
} |
| 995 |
} |
| 996 |
setEventListener(setup) { |
| 997 |
this.#setup = setup; |
| 998 |
this.#cleanup?.(); |
| 999 |
this.#cleanup = setup(this.setOnline.bind(this)); |
| 1000 |
} |
| 1001 |
setOnline(online) { |
| 1002 |
const changed = this.#online !== online; |
| 1003 |
if (changed) { |
| 1004 |
this.#online = online; |
| 1005 |
this.listeners.forEach((listener) => { |
| 1006 |
listener(online); |
| 1007 |
}); |
| 1008 |
} |
| 1009 |
} |
| 1010 |
isOnline() { |
| 1011 |
return this.#online; |
| 1012 |
} |
| 1013 |
}; |
| 1014 |
var onlineManager = new OnlineManager(); |
| 1015 |
|
| 1016 |
//# sourceMappingURL=onlineManager.js.map |
| 1017 |
|
| 1018 |
/***/ }), |
| 1019 |
|
| 1020 |
/***/ "./node_modules/@tanstack/query-core/build/modern/query.js": |
| 1021 |
/*!*****************************************************************!*\ |
| 1022 |
!*** ./node_modules/@tanstack/query-core/build/modern/query.js ***! |
| 1023 |
\*****************************************************************/ |
| 1024 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1025 |
|
| 1026 |
__webpack_require__.r(__webpack_exports__); |
| 1027 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1028 |
/* harmony export */ Query: function() { return /* binding */ Query; }, |
| 1029 |
/* harmony export */ fetchState: function() { return /* binding */ fetchState; } |
| 1030 |
/* harmony export */ }); |
| 1031 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1032 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1033 |
/* harmony import */ var _retryer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./retryer.js */ "./node_modules/@tanstack/query-core/build/modern/retryer.js"); |
| 1034 |
/* harmony import */ var _removable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./removable.js */ "./node_modules/@tanstack/query-core/build/modern/removable.js"); |
| 1035 |
// src/query.ts |
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
var Query = class extends _removable_js__WEBPACK_IMPORTED_MODULE_3__.Removable { |
| 1041 |
#initialState; |
| 1042 |
#revertState; |
| 1043 |
#cache; |
| 1044 |
#client; |
| 1045 |
#retryer; |
| 1046 |
#defaultOptions; |
| 1047 |
#abortSignalConsumed; |
| 1048 |
constructor(config) { |
| 1049 |
super(); |
| 1050 |
this.#abortSignalConsumed = false; |
| 1051 |
this.#defaultOptions = config.defaultOptions; |
| 1052 |
this.setOptions(config.options); |
| 1053 |
this.observers = []; |
| 1054 |
this.#client = config.client; |
| 1055 |
this.#cache = this.#client.getQueryCache(); |
| 1056 |
this.queryKey = config.queryKey; |
| 1057 |
this.queryHash = config.queryHash; |
| 1058 |
this.#initialState = getDefaultState(this.options); |
| 1059 |
this.state = config.state ?? this.#initialState; |
| 1060 |
this.scheduleGc(); |
| 1061 |
} |
| 1062 |
get meta() { |
| 1063 |
return this.options.meta; |
| 1064 |
} |
| 1065 |
get promise() { |
| 1066 |
return this.#retryer?.promise; |
| 1067 |
} |
| 1068 |
setOptions(options) { |
| 1069 |
this.options = { ...this.#defaultOptions, ...options }; |
| 1070 |
this.updateGcTime(this.options.gcTime); |
| 1071 |
if (this.state && this.state.data === void 0) { |
| 1072 |
const defaultState = getDefaultState(this.options); |
| 1073 |
if (defaultState.data !== void 0) { |
| 1074 |
this.setState( |
| 1075 |
successState(defaultState.data, defaultState.dataUpdatedAt) |
| 1076 |
); |
| 1077 |
this.#initialState = defaultState; |
| 1078 |
} |
| 1079 |
} |
| 1080 |
} |
| 1081 |
optionalRemove() { |
| 1082 |
if (!this.observers.length && this.state.fetchStatus === "idle") { |
| 1083 |
this.#cache.remove(this); |
| 1084 |
} |
| 1085 |
} |
| 1086 |
setData(newData, options) { |
| 1087 |
const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.replaceData)(this.state.data, newData, this.options); |
| 1088 |
this.#dispatch({ |
| 1089 |
data, |
| 1090 |
type: "success", |
| 1091 |
dataUpdatedAt: options?.updatedAt, |
| 1092 |
manual: options?.manual |
| 1093 |
}); |
| 1094 |
return data; |
| 1095 |
} |
| 1096 |
setState(state, setStateOptions) { |
| 1097 |
this.#dispatch({ type: "setState", state, setStateOptions }); |
| 1098 |
} |
| 1099 |
cancel(options) { |
| 1100 |
const promise = this.#retryer?.promise; |
| 1101 |
this.#retryer?.cancel(options); |
| 1102 |
return promise ? promise.then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop) : Promise.resolve(); |
| 1103 |
} |
| 1104 |
destroy() { |
| 1105 |
super.destroy(); |
| 1106 |
this.cancel({ silent: true }); |
| 1107 |
} |
| 1108 |
reset() { |
| 1109 |
this.destroy(); |
| 1110 |
this.setState(this.#initialState); |
| 1111 |
} |
| 1112 |
isActive() { |
| 1113 |
return this.observers.some( |
| 1114 |
(observer) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveEnabled)(observer.options.enabled, this) !== false |
| 1115 |
); |
| 1116 |
} |
| 1117 |
isDisabled() { |
| 1118 |
if (this.getObserversCount() > 0) { |
| 1119 |
return !this.isActive(); |
| 1120 |
} |
| 1121 |
return this.options.queryFn === _utils_js__WEBPACK_IMPORTED_MODULE_0__.skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0; |
| 1122 |
} |
| 1123 |
isStatic() { |
| 1124 |
if (this.getObserversCount() > 0) { |
| 1125 |
return this.observers.some( |
| 1126 |
(observer) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveStaleTime)(observer.options.staleTime, this) === "static" |
| 1127 |
); |
| 1128 |
} |
| 1129 |
return false; |
| 1130 |
} |
| 1131 |
isStale() { |
| 1132 |
if (this.getObserversCount() > 0) { |
| 1133 |
return this.observers.some( |
| 1134 |
(observer) => observer.getCurrentResult().isStale |
| 1135 |
); |
| 1136 |
} |
| 1137 |
return this.state.data === void 0 || this.state.isInvalidated; |
| 1138 |
} |
| 1139 |
isStaleByTime(staleTime = 0) { |
| 1140 |
if (this.state.data === void 0) { |
| 1141 |
return true; |
| 1142 |
} |
| 1143 |
if (staleTime === "static") { |
| 1144 |
return false; |
| 1145 |
} |
| 1146 |
if (this.state.isInvalidated) { |
| 1147 |
return true; |
| 1148 |
} |
| 1149 |
return !(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.timeUntilStale)(this.state.dataUpdatedAt, staleTime); |
| 1150 |
} |
| 1151 |
onFocus() { |
| 1152 |
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus()); |
| 1153 |
observer?.refetch({ cancelRefetch: false }); |
| 1154 |
this.#retryer?.continue(); |
| 1155 |
} |
| 1156 |
onOnline() { |
| 1157 |
const observer = this.observers.find((x) => x.shouldFetchOnReconnect()); |
| 1158 |
observer?.refetch({ cancelRefetch: false }); |
| 1159 |
this.#retryer?.continue(); |
| 1160 |
} |
| 1161 |
addObserver(observer) { |
| 1162 |
if (!this.observers.includes(observer)) { |
| 1163 |
this.observers.push(observer); |
| 1164 |
this.clearGcTimeout(); |
| 1165 |
this.#cache.notify({ type: "observerAdded", query: this, observer }); |
| 1166 |
} |
| 1167 |
} |
| 1168 |
removeObserver(observer) { |
| 1169 |
if (this.observers.includes(observer)) { |
| 1170 |
this.observers = this.observers.filter((x) => x !== observer); |
| 1171 |
if (!this.observers.length) { |
| 1172 |
if (this.#retryer) { |
| 1173 |
if (this.#abortSignalConsumed) { |
| 1174 |
this.#retryer.cancel({ revert: true }); |
| 1175 |
} else { |
| 1176 |
this.#retryer.cancelRetry(); |
| 1177 |
} |
| 1178 |
} |
| 1179 |
this.scheduleGc(); |
| 1180 |
} |
| 1181 |
this.#cache.notify({ type: "observerRemoved", query: this, observer }); |
| 1182 |
} |
| 1183 |
} |
| 1184 |
getObserversCount() { |
| 1185 |
return this.observers.length; |
| 1186 |
} |
| 1187 |
invalidate() { |
| 1188 |
if (!this.state.isInvalidated) { |
| 1189 |
this.#dispatch({ type: "invalidate" }); |
| 1190 |
} |
| 1191 |
} |
| 1192 |
async fetch(options, fetchOptions) { |
| 1193 |
if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely |
| 1194 |
// re-start the fetch; there is a chance that the query is still in a |
| 1195 |
// pending state when that happens |
| 1196 |
this.#retryer?.status() !== "rejected") { |
| 1197 |
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) { |
| 1198 |
this.cancel({ silent: true }); |
| 1199 |
} else if (this.#retryer) { |
| 1200 |
this.#retryer.continueRetry(); |
| 1201 |
return this.#retryer.promise; |
| 1202 |
} |
| 1203 |
} |
| 1204 |
if (options) { |
| 1205 |
this.setOptions(options); |
| 1206 |
} |
| 1207 |
if (!this.options.queryFn) { |
| 1208 |
const observer = this.observers.find((x) => x.options.queryFn); |
| 1209 |
if (observer) { |
| 1210 |
this.setOptions(observer.options); |
| 1211 |
} |
| 1212 |
} |
| 1213 |
if (true) { |
| 1214 |
if (!Array.isArray(this.options.queryKey)) { |
| 1215 |
console.error( |
| 1216 |
`As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']` |
| 1217 |
); |
| 1218 |
} |
| 1219 |
} |
| 1220 |
const abortController = new AbortController(); |
| 1221 |
const addSignalProperty = (object) => { |
| 1222 |
Object.defineProperty(object, "signal", { |
| 1223 |
enumerable: true, |
| 1224 |
get: () => { |
| 1225 |
this.#abortSignalConsumed = true; |
| 1226 |
return abortController.signal; |
| 1227 |
} |
| 1228 |
}); |
| 1229 |
}; |
| 1230 |
const fetchFn = () => { |
| 1231 |
const queryFn = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.ensureQueryFn)(this.options, fetchOptions); |
| 1232 |
const createQueryFnContext = () => { |
| 1233 |
const queryFnContext2 = { |
| 1234 |
client: this.#client, |
| 1235 |
queryKey: this.queryKey, |
| 1236 |
meta: this.meta |
| 1237 |
}; |
| 1238 |
addSignalProperty(queryFnContext2); |
| 1239 |
return queryFnContext2; |
| 1240 |
}; |
| 1241 |
const queryFnContext = createQueryFnContext(); |
| 1242 |
this.#abortSignalConsumed = false; |
| 1243 |
if (this.options.persister) { |
| 1244 |
return this.options.persister( |
| 1245 |
queryFn, |
| 1246 |
queryFnContext, |
| 1247 |
this |
| 1248 |
); |
| 1249 |
} |
| 1250 |
return queryFn(queryFnContext); |
| 1251 |
}; |
| 1252 |
const createFetchContext = () => { |
| 1253 |
const context2 = { |
| 1254 |
fetchOptions, |
| 1255 |
options: this.options, |
| 1256 |
queryKey: this.queryKey, |
| 1257 |
client: this.#client, |
| 1258 |
state: this.state, |
| 1259 |
fetchFn |
| 1260 |
}; |
| 1261 |
addSignalProperty(context2); |
| 1262 |
return context2; |
| 1263 |
}; |
| 1264 |
const context = createFetchContext(); |
| 1265 |
this.options.behavior?.onFetch(context, this); |
| 1266 |
this.#revertState = this.state; |
| 1267 |
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) { |
| 1268 |
this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta }); |
| 1269 |
} |
| 1270 |
this.#retryer = (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.createRetryer)({ |
| 1271 |
initialPromise: fetchOptions?.initialPromise, |
| 1272 |
fn: context.fetchFn, |
| 1273 |
onCancel: (error) => { |
| 1274 |
if (error instanceof _retryer_js__WEBPACK_IMPORTED_MODULE_2__.CancelledError && error.revert) { |
| 1275 |
this.setState({ |
| 1276 |
...this.#revertState, |
| 1277 |
fetchStatus: "idle" |
| 1278 |
}); |
| 1279 |
} |
| 1280 |
abortController.abort(); |
| 1281 |
}, |
| 1282 |
onFail: (failureCount, error) => { |
| 1283 |
this.#dispatch({ type: "failed", failureCount, error }); |
| 1284 |
}, |
| 1285 |
onPause: () => { |
| 1286 |
this.#dispatch({ type: "pause" }); |
| 1287 |
}, |
| 1288 |
onContinue: () => { |
| 1289 |
this.#dispatch({ type: "continue" }); |
| 1290 |
}, |
| 1291 |
retry: context.options.retry, |
| 1292 |
retryDelay: context.options.retryDelay, |
| 1293 |
networkMode: context.options.networkMode, |
| 1294 |
canRun: () => true |
| 1295 |
}); |
| 1296 |
try { |
| 1297 |
const data = await this.#retryer.start(); |
| 1298 |
if (data === void 0) { |
| 1299 |
if (true) { |
| 1300 |
console.error( |
| 1301 |
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}` |
| 1302 |
); |
| 1303 |
} |
| 1304 |
throw new Error(`${this.queryHash} data is undefined`); |
| 1305 |
} |
| 1306 |
this.setData(data); |
| 1307 |
this.#cache.config.onSuccess?.(data, this); |
| 1308 |
this.#cache.config.onSettled?.( |
| 1309 |
data, |
| 1310 |
this.state.error, |
| 1311 |
this |
| 1312 |
); |
| 1313 |
return data; |
| 1314 |
} catch (error) { |
| 1315 |
if (error instanceof _retryer_js__WEBPACK_IMPORTED_MODULE_2__.CancelledError) { |
| 1316 |
if (error.silent) { |
| 1317 |
return this.#retryer.promise; |
| 1318 |
} else if (error.revert) { |
| 1319 |
if (this.state.data === void 0) { |
| 1320 |
throw error; |
| 1321 |
} |
| 1322 |
return this.state.data; |
| 1323 |
} |
| 1324 |
} |
| 1325 |
this.#dispatch({ |
| 1326 |
type: "error", |
| 1327 |
error |
| 1328 |
}); |
| 1329 |
this.#cache.config.onError?.( |
| 1330 |
error, |
| 1331 |
this |
| 1332 |
); |
| 1333 |
this.#cache.config.onSettled?.( |
| 1334 |
this.state.data, |
| 1335 |
error, |
| 1336 |
this |
| 1337 |
); |
| 1338 |
throw error; |
| 1339 |
} finally { |
| 1340 |
this.scheduleGc(); |
| 1341 |
} |
| 1342 |
} |
| 1343 |
#dispatch(action) { |
| 1344 |
const reducer = (state) => { |
| 1345 |
switch (action.type) { |
| 1346 |
case "failed": |
| 1347 |
return { |
| 1348 |
...state, |
| 1349 |
fetchFailureCount: action.failureCount, |
| 1350 |
fetchFailureReason: action.error |
| 1351 |
}; |
| 1352 |
case "pause": |
| 1353 |
return { |
| 1354 |
...state, |
| 1355 |
fetchStatus: "paused" |
| 1356 |
}; |
| 1357 |
case "continue": |
| 1358 |
return { |
| 1359 |
...state, |
| 1360 |
fetchStatus: "fetching" |
| 1361 |
}; |
| 1362 |
case "fetch": |
| 1363 |
return { |
| 1364 |
...state, |
| 1365 |
...fetchState(state.data, this.options), |
| 1366 |
fetchMeta: action.meta ?? null |
| 1367 |
}; |
| 1368 |
case "success": |
| 1369 |
const newState = { |
| 1370 |
...state, |
| 1371 |
...successState(action.data, action.dataUpdatedAt), |
| 1372 |
dataUpdateCount: state.dataUpdateCount + 1, |
| 1373 |
...!action.manual && { |
| 1374 |
fetchStatus: "idle", |
| 1375 |
fetchFailureCount: 0, |
| 1376 |
fetchFailureReason: null |
| 1377 |
} |
| 1378 |
}; |
| 1379 |
this.#revertState = action.manual ? newState : void 0; |
| 1380 |
return newState; |
| 1381 |
case "error": |
| 1382 |
const error = action.error; |
| 1383 |
return { |
| 1384 |
...state, |
| 1385 |
error, |
| 1386 |
errorUpdateCount: state.errorUpdateCount + 1, |
| 1387 |
errorUpdatedAt: Date.now(), |
| 1388 |
fetchFailureCount: state.fetchFailureCount + 1, |
| 1389 |
fetchFailureReason: error, |
| 1390 |
fetchStatus: "idle", |
| 1391 |
status: "error" |
| 1392 |
}; |
| 1393 |
case "invalidate": |
| 1394 |
return { |
| 1395 |
...state, |
| 1396 |
isInvalidated: true |
| 1397 |
}; |
| 1398 |
case "setState": |
| 1399 |
return { |
| 1400 |
...state, |
| 1401 |
...action.state |
| 1402 |
}; |
| 1403 |
} |
| 1404 |
}; |
| 1405 |
this.state = reducer(this.state); |
| 1406 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batch(() => { |
| 1407 |
this.observers.forEach((observer) => { |
| 1408 |
observer.onQueryUpdate(); |
| 1409 |
}); |
| 1410 |
this.#cache.notify({ query: this, type: "updated", action }); |
| 1411 |
}); |
| 1412 |
} |
| 1413 |
}; |
| 1414 |
function fetchState(data, options) { |
| 1415 |
return { |
| 1416 |
fetchFailureCount: 0, |
| 1417 |
fetchFailureReason: null, |
| 1418 |
fetchStatus: (0,_retryer_js__WEBPACK_IMPORTED_MODULE_2__.canFetch)(options.networkMode) ? "fetching" : "paused", |
| 1419 |
...data === void 0 && { |
| 1420 |
error: null, |
| 1421 |
status: "pending" |
| 1422 |
} |
| 1423 |
}; |
| 1424 |
} |
| 1425 |
function successState(data, dataUpdatedAt) { |
| 1426 |
return { |
| 1427 |
data, |
| 1428 |
dataUpdatedAt: dataUpdatedAt ?? Date.now(), |
| 1429 |
error: null, |
| 1430 |
isInvalidated: false, |
| 1431 |
status: "success" |
| 1432 |
}; |
| 1433 |
} |
| 1434 |
function getDefaultState(options) { |
| 1435 |
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData; |
| 1436 |
const hasData = data !== void 0; |
| 1437 |
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; |
| 1438 |
return { |
| 1439 |
data, |
| 1440 |
dataUpdateCount: 0, |
| 1441 |
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0, |
| 1442 |
error: null, |
| 1443 |
errorUpdateCount: 0, |
| 1444 |
errorUpdatedAt: 0, |
| 1445 |
fetchFailureCount: 0, |
| 1446 |
fetchFailureReason: null, |
| 1447 |
fetchMeta: null, |
| 1448 |
isInvalidated: false, |
| 1449 |
status: hasData ? "success" : "pending", |
| 1450 |
fetchStatus: "idle" |
| 1451 |
}; |
| 1452 |
} |
| 1453 |
|
| 1454 |
//# sourceMappingURL=query.js.map |
| 1455 |
|
| 1456 |
/***/ }), |
| 1457 |
|
| 1458 |
/***/ "./node_modules/@tanstack/query-core/build/modern/queryCache.js": |
| 1459 |
/*!**********************************************************************!*\ |
| 1460 |
!*** ./node_modules/@tanstack/query-core/build/modern/queryCache.js ***! |
| 1461 |
\**********************************************************************/ |
| 1462 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1463 |
|
| 1464 |
__webpack_require__.r(__webpack_exports__); |
| 1465 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1466 |
/* harmony export */ QueryCache: function() { return /* binding */ QueryCache; } |
| 1467 |
/* harmony export */ }); |
| 1468 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1469 |
/* harmony import */ var _query_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./query.js */ "./node_modules/@tanstack/query-core/build/modern/query.js"); |
| 1470 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1471 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 1472 |
// src/queryCache.ts |
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
var QueryCache = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_3__.Subscribable { |
| 1478 |
constructor(config = {}) { |
| 1479 |
super(); |
| 1480 |
this.config = config; |
| 1481 |
this.#queries = /* @__PURE__ */ new Map(); |
| 1482 |
} |
| 1483 |
#queries; |
| 1484 |
build(client, options, state) { |
| 1485 |
const queryKey = options.queryKey; |
| 1486 |
const queryHash = options.queryHash ?? (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashQueryKeyByOptions)(queryKey, options); |
| 1487 |
let query = this.get(queryHash); |
| 1488 |
if (!query) { |
| 1489 |
query = new _query_js__WEBPACK_IMPORTED_MODULE_1__.Query({ |
| 1490 |
client, |
| 1491 |
queryKey, |
| 1492 |
queryHash, |
| 1493 |
options: client.defaultQueryOptions(options), |
| 1494 |
state, |
| 1495 |
defaultOptions: client.getQueryDefaults(queryKey) |
| 1496 |
}); |
| 1497 |
this.add(query); |
| 1498 |
} |
| 1499 |
return query; |
| 1500 |
} |
| 1501 |
add(query) { |
| 1502 |
if (!this.#queries.has(query.queryHash)) { |
| 1503 |
this.#queries.set(query.queryHash, query); |
| 1504 |
this.notify({ |
| 1505 |
type: "added", |
| 1506 |
query |
| 1507 |
}); |
| 1508 |
} |
| 1509 |
} |
| 1510 |
remove(query) { |
| 1511 |
const queryInMap = this.#queries.get(query.queryHash); |
| 1512 |
if (queryInMap) { |
| 1513 |
query.destroy(); |
| 1514 |
if (queryInMap === query) { |
| 1515 |
this.#queries.delete(query.queryHash); |
| 1516 |
} |
| 1517 |
this.notify({ type: "removed", query }); |
| 1518 |
} |
| 1519 |
} |
| 1520 |
clear() { |
| 1521 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 1522 |
this.getAll().forEach((query) => { |
| 1523 |
this.remove(query); |
| 1524 |
}); |
| 1525 |
}); |
| 1526 |
} |
| 1527 |
get(queryHash) { |
| 1528 |
return this.#queries.get(queryHash); |
| 1529 |
} |
| 1530 |
getAll() { |
| 1531 |
return [...this.#queries.values()]; |
| 1532 |
} |
| 1533 |
find(filters) { |
| 1534 |
const defaultedFilters = { exact: true, ...filters }; |
| 1535 |
return this.getAll().find( |
| 1536 |
(query) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.matchQuery)(defaultedFilters, query) |
| 1537 |
); |
| 1538 |
} |
| 1539 |
findAll(filters = {}) { |
| 1540 |
const queries = this.getAll(); |
| 1541 |
return Object.keys(filters).length > 0 ? queries.filter((query) => (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.matchQuery)(filters, query)) : queries; |
| 1542 |
} |
| 1543 |
notify(event) { |
| 1544 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 1545 |
this.listeners.forEach((listener) => { |
| 1546 |
listener(event); |
| 1547 |
}); |
| 1548 |
}); |
| 1549 |
} |
| 1550 |
onFocus() { |
| 1551 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 1552 |
this.getAll().forEach((query) => { |
| 1553 |
query.onFocus(); |
| 1554 |
}); |
| 1555 |
}); |
| 1556 |
} |
| 1557 |
onOnline() { |
| 1558 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batch(() => { |
| 1559 |
this.getAll().forEach((query) => { |
| 1560 |
query.onOnline(); |
| 1561 |
}); |
| 1562 |
}); |
| 1563 |
} |
| 1564 |
}; |
| 1565 |
|
| 1566 |
//# sourceMappingURL=queryCache.js.map |
| 1567 |
|
| 1568 |
/***/ }), |
| 1569 |
|
| 1570 |
/***/ "./node_modules/@tanstack/query-core/build/modern/queryClient.js": |
| 1571 |
/*!***********************************************************************!*\ |
| 1572 |
!*** ./node_modules/@tanstack/query-core/build/modern/queryClient.js ***! |
| 1573 |
\***********************************************************************/ |
| 1574 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1575 |
|
| 1576 |
__webpack_require__.r(__webpack_exports__); |
| 1577 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1578 |
/* harmony export */ QueryClient: function() { return /* binding */ QueryClient; } |
| 1579 |
/* harmony export */ }); |
| 1580 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1581 |
/* harmony import */ var _queryCache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./queryCache.js */ "./node_modules/@tanstack/query-core/build/modern/queryCache.js"); |
| 1582 |
/* harmony import */ var _mutationCache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mutationCache.js */ "./node_modules/@tanstack/query-core/build/modern/mutationCache.js"); |
| 1583 |
/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); |
| 1584 |
/* harmony import */ var _onlineManager_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./onlineManager.js */ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js"); |
| 1585 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1586 |
/* harmony import */ var _infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./infiniteQueryBehavior.js */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js"); |
| 1587 |
// src/queryClient.ts |
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
var QueryClient = class { |
| 1596 |
#queryCache; |
| 1597 |
#mutationCache; |
| 1598 |
#defaultOptions; |
| 1599 |
#queryDefaults; |
| 1600 |
#mutationDefaults; |
| 1601 |
#mountCount; |
| 1602 |
#unsubscribeFocus; |
| 1603 |
#unsubscribeOnline; |
| 1604 |
constructor(config = {}) { |
| 1605 |
this.#queryCache = config.queryCache || new _queryCache_js__WEBPACK_IMPORTED_MODULE_1__.QueryCache(); |
| 1606 |
this.#mutationCache = config.mutationCache || new _mutationCache_js__WEBPACK_IMPORTED_MODULE_2__.MutationCache(); |
| 1607 |
this.#defaultOptions = config.defaultOptions || {}; |
| 1608 |
this.#queryDefaults = /* @__PURE__ */ new Map(); |
| 1609 |
this.#mutationDefaults = /* @__PURE__ */ new Map(); |
| 1610 |
this.#mountCount = 0; |
| 1611 |
} |
| 1612 |
mount() { |
| 1613 |
this.#mountCount++; |
| 1614 |
if (this.#mountCount !== 1) return; |
| 1615 |
this.#unsubscribeFocus = _focusManager_js__WEBPACK_IMPORTED_MODULE_3__.focusManager.subscribe(async (focused) => { |
| 1616 |
if (focused) { |
| 1617 |
await this.resumePausedMutations(); |
| 1618 |
this.#queryCache.onFocus(); |
| 1619 |
} |
| 1620 |
}); |
| 1621 |
this.#unsubscribeOnline = _onlineManager_js__WEBPACK_IMPORTED_MODULE_4__.onlineManager.subscribe(async (online) => { |
| 1622 |
if (online) { |
| 1623 |
await this.resumePausedMutations(); |
| 1624 |
this.#queryCache.onOnline(); |
| 1625 |
} |
| 1626 |
}); |
| 1627 |
} |
| 1628 |
unmount() { |
| 1629 |
this.#mountCount--; |
| 1630 |
if (this.#mountCount !== 0) return; |
| 1631 |
this.#unsubscribeFocus?.(); |
| 1632 |
this.#unsubscribeFocus = void 0; |
| 1633 |
this.#unsubscribeOnline?.(); |
| 1634 |
this.#unsubscribeOnline = void 0; |
| 1635 |
} |
| 1636 |
isFetching(filters) { |
| 1637 |
return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length; |
| 1638 |
} |
| 1639 |
isMutating(filters) { |
| 1640 |
return this.#mutationCache.findAll({ ...filters, status: "pending" }).length; |
| 1641 |
} |
| 1642 |
/** |
| 1643 |
* Imperative (non-reactive) way to retrieve data for a QueryKey. |
| 1644 |
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. |
| 1645 |
* |
| 1646 |
* Hint: Do not use this function inside a component, because it won't receive updates. |
| 1647 |
* Use `useQuery` to create a `QueryObserver` that subscribes to changes. |
| 1648 |
*/ |
| 1649 |
getQueryData(queryKey) { |
| 1650 |
const options = this.defaultQueryOptions({ queryKey }); |
| 1651 |
return this.#queryCache.get(options.queryHash)?.state.data; |
| 1652 |
} |
| 1653 |
ensureQueryData(options) { |
| 1654 |
const defaultedOptions = this.defaultQueryOptions(options); |
| 1655 |
const query = this.#queryCache.build(this, defaultedOptions); |
| 1656 |
const cachedData = query.state.data; |
| 1657 |
if (cachedData === void 0) { |
| 1658 |
return this.fetchQuery(options); |
| 1659 |
} |
| 1660 |
if (options.revalidateIfStale && query.isStaleByTime((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveStaleTime)(defaultedOptions.staleTime, query))) { |
| 1661 |
void this.prefetchQuery(defaultedOptions); |
| 1662 |
} |
| 1663 |
return Promise.resolve(cachedData); |
| 1664 |
} |
| 1665 |
getQueriesData(filters) { |
| 1666 |
return this.#queryCache.findAll(filters).map(({ queryKey, state }) => { |
| 1667 |
const data = state.data; |
| 1668 |
return [queryKey, data]; |
| 1669 |
}); |
| 1670 |
} |
| 1671 |
setQueryData(queryKey, updater, options) { |
| 1672 |
const defaultedOptions = this.defaultQueryOptions({ queryKey }); |
| 1673 |
const query = this.#queryCache.get( |
| 1674 |
defaultedOptions.queryHash |
| 1675 |
); |
| 1676 |
const prevData = query?.state.data; |
| 1677 |
const data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.functionalUpdate)(updater, prevData); |
| 1678 |
if (data === void 0) { |
| 1679 |
return void 0; |
| 1680 |
} |
| 1681 |
return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true }); |
| 1682 |
} |
| 1683 |
setQueriesData(filters, updater, options) { |
| 1684 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( |
| 1685 |
() => this.#queryCache.findAll(filters).map(({ queryKey }) => [ |
| 1686 |
queryKey, |
| 1687 |
this.setQueryData(queryKey, updater, options) |
| 1688 |
]) |
| 1689 |
); |
| 1690 |
} |
| 1691 |
getQueryState(queryKey) { |
| 1692 |
const options = this.defaultQueryOptions({ queryKey }); |
| 1693 |
return this.#queryCache.get( |
| 1694 |
options.queryHash |
| 1695 |
)?.state; |
| 1696 |
} |
| 1697 |
removeQueries(filters) { |
| 1698 |
const queryCache = this.#queryCache; |
| 1699 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { |
| 1700 |
queryCache.findAll(filters).forEach((query) => { |
| 1701 |
queryCache.remove(query); |
| 1702 |
}); |
| 1703 |
}); |
| 1704 |
} |
| 1705 |
resetQueries(filters, options) { |
| 1706 |
const queryCache = this.#queryCache; |
| 1707 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { |
| 1708 |
queryCache.findAll(filters).forEach((query) => { |
| 1709 |
query.reset(); |
| 1710 |
}); |
| 1711 |
return this.refetchQueries( |
| 1712 |
{ |
| 1713 |
type: "active", |
| 1714 |
...filters |
| 1715 |
}, |
| 1716 |
options |
| 1717 |
); |
| 1718 |
}); |
| 1719 |
} |
| 1720 |
cancelQueries(filters, cancelOptions = {}) { |
| 1721 |
const defaultedCancelOptions = { revert: true, ...cancelOptions }; |
| 1722 |
const promises = _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( |
| 1723 |
() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)) |
| 1724 |
); |
| 1725 |
return Promise.all(promises).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); |
| 1726 |
} |
| 1727 |
invalidateQueries(filters, options = {}) { |
| 1728 |
return _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch(() => { |
| 1729 |
this.#queryCache.findAll(filters).forEach((query) => { |
| 1730 |
query.invalidate(); |
| 1731 |
}); |
| 1732 |
if (filters?.refetchType === "none") { |
| 1733 |
return Promise.resolve(); |
| 1734 |
} |
| 1735 |
return this.refetchQueries( |
| 1736 |
{ |
| 1737 |
...filters, |
| 1738 |
type: filters?.refetchType ?? filters?.type ?? "active" |
| 1739 |
}, |
| 1740 |
options |
| 1741 |
); |
| 1742 |
}); |
| 1743 |
} |
| 1744 |
refetchQueries(filters, options = {}) { |
| 1745 |
const fetchOptions = { |
| 1746 |
...options, |
| 1747 |
cancelRefetch: options.cancelRefetch ?? true |
| 1748 |
}; |
| 1749 |
const promises = _notifyManager_js__WEBPACK_IMPORTED_MODULE_5__.notifyManager.batch( |
| 1750 |
() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => { |
| 1751 |
let promise = query.fetch(void 0, fetchOptions); |
| 1752 |
if (!fetchOptions.throwOnError) { |
| 1753 |
promise = promise.catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); |
| 1754 |
} |
| 1755 |
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise; |
| 1756 |
}) |
| 1757 |
); |
| 1758 |
return Promise.all(promises).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); |
| 1759 |
} |
| 1760 |
fetchQuery(options) { |
| 1761 |
const defaultedOptions = this.defaultQueryOptions(options); |
| 1762 |
if (defaultedOptions.retry === void 0) { |
| 1763 |
defaultedOptions.retry = false; |
| 1764 |
} |
| 1765 |
const query = this.#queryCache.build(this, defaultedOptions); |
| 1766 |
return query.isStaleByTime( |
| 1767 |
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.resolveStaleTime)(defaultedOptions.staleTime, query) |
| 1768 |
) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); |
| 1769 |
} |
| 1770 |
prefetchQuery(options) { |
| 1771 |
return this.fetchQuery(options).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); |
| 1772 |
} |
| 1773 |
fetchInfiniteQuery(options) { |
| 1774 |
options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__.infiniteQueryBehavior)(options.pages); |
| 1775 |
return this.fetchQuery(options); |
| 1776 |
} |
| 1777 |
prefetchInfiniteQuery(options) { |
| 1778 |
return this.fetchInfiniteQuery(options).then(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop).catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); |
| 1779 |
} |
| 1780 |
ensureInfiniteQueryData(options) { |
| 1781 |
options.behavior = (0,_infiniteQueryBehavior_js__WEBPACK_IMPORTED_MODULE_6__.infiniteQueryBehavior)(options.pages); |
| 1782 |
return this.ensureQueryData(options); |
| 1783 |
} |
| 1784 |
resumePausedMutations() { |
| 1785 |
if (_onlineManager_js__WEBPACK_IMPORTED_MODULE_4__.onlineManager.isOnline()) { |
| 1786 |
return this.#mutationCache.resumePausedMutations(); |
| 1787 |
} |
| 1788 |
return Promise.resolve(); |
| 1789 |
} |
| 1790 |
getQueryCache() { |
| 1791 |
return this.#queryCache; |
| 1792 |
} |
| 1793 |
getMutationCache() { |
| 1794 |
return this.#mutationCache; |
| 1795 |
} |
| 1796 |
getDefaultOptions() { |
| 1797 |
return this.#defaultOptions; |
| 1798 |
} |
| 1799 |
setDefaultOptions(options) { |
| 1800 |
this.#defaultOptions = options; |
| 1801 |
} |
| 1802 |
setQueryDefaults(queryKey, options) { |
| 1803 |
this.#queryDefaults.set((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashKey)(queryKey), { |
| 1804 |
queryKey, |
| 1805 |
defaultOptions: options |
| 1806 |
}); |
| 1807 |
} |
| 1808 |
getQueryDefaults(queryKey) { |
| 1809 |
const defaults = [...this.#queryDefaults.values()]; |
| 1810 |
const result = {}; |
| 1811 |
defaults.forEach((queryDefault) => { |
| 1812 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.partialMatchKey)(queryKey, queryDefault.queryKey)) { |
| 1813 |
Object.assign(result, queryDefault.defaultOptions); |
| 1814 |
} |
| 1815 |
}); |
| 1816 |
return result; |
| 1817 |
} |
| 1818 |
setMutationDefaults(mutationKey, options) { |
| 1819 |
this.#mutationDefaults.set((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashKey)(mutationKey), { |
| 1820 |
mutationKey, |
| 1821 |
defaultOptions: options |
| 1822 |
}); |
| 1823 |
} |
| 1824 |
getMutationDefaults(mutationKey) { |
| 1825 |
const defaults = [...this.#mutationDefaults.values()]; |
| 1826 |
const result = {}; |
| 1827 |
defaults.forEach((queryDefault) => { |
| 1828 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.partialMatchKey)(mutationKey, queryDefault.mutationKey)) { |
| 1829 |
Object.assign(result, queryDefault.defaultOptions); |
| 1830 |
} |
| 1831 |
}); |
| 1832 |
return result; |
| 1833 |
} |
| 1834 |
defaultQueryOptions(options) { |
| 1835 |
if (options._defaulted) { |
| 1836 |
return options; |
| 1837 |
} |
| 1838 |
const defaultedOptions = { |
| 1839 |
...this.#defaultOptions.queries, |
| 1840 |
...this.getQueryDefaults(options.queryKey), |
| 1841 |
...options, |
| 1842 |
_defaulted: true |
| 1843 |
}; |
| 1844 |
if (!defaultedOptions.queryHash) { |
| 1845 |
defaultedOptions.queryHash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.hashQueryKeyByOptions)( |
| 1846 |
defaultedOptions.queryKey, |
| 1847 |
defaultedOptions |
| 1848 |
); |
| 1849 |
} |
| 1850 |
if (defaultedOptions.refetchOnReconnect === void 0) { |
| 1851 |
defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always"; |
| 1852 |
} |
| 1853 |
if (defaultedOptions.throwOnError === void 0) { |
| 1854 |
defaultedOptions.throwOnError = !!defaultedOptions.suspense; |
| 1855 |
} |
| 1856 |
if (!defaultedOptions.networkMode && defaultedOptions.persister) { |
| 1857 |
defaultedOptions.networkMode = "offlineFirst"; |
| 1858 |
} |
| 1859 |
if (defaultedOptions.queryFn === _utils_js__WEBPACK_IMPORTED_MODULE_0__.skipToken) { |
| 1860 |
defaultedOptions.enabled = false; |
| 1861 |
} |
| 1862 |
return defaultedOptions; |
| 1863 |
} |
| 1864 |
defaultMutationOptions(options) { |
| 1865 |
if (options?._defaulted) { |
| 1866 |
return options; |
| 1867 |
} |
| 1868 |
return { |
| 1869 |
...this.#defaultOptions.mutations, |
| 1870 |
...options?.mutationKey && this.getMutationDefaults(options.mutationKey), |
| 1871 |
...options, |
| 1872 |
_defaulted: true |
| 1873 |
}; |
| 1874 |
} |
| 1875 |
clear() { |
| 1876 |
this.#queryCache.clear(); |
| 1877 |
this.#mutationCache.clear(); |
| 1878 |
} |
| 1879 |
}; |
| 1880 |
|
| 1881 |
//# sourceMappingURL=queryClient.js.map |
| 1882 |
|
| 1883 |
/***/ }), |
| 1884 |
|
| 1885 |
/***/ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js": |
| 1886 |
/*!*************************************************************************!*\ |
| 1887 |
!*** ./node_modules/@tanstack/query-core/build/modern/queryObserver.js ***! |
| 1888 |
\*************************************************************************/ |
| 1889 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 1890 |
|
| 1891 |
__webpack_require__.r(__webpack_exports__); |
| 1892 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1893 |
/* harmony export */ QueryObserver: function() { return /* binding */ QueryObserver; } |
| 1894 |
/* harmony export */ }); |
| 1895 |
/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); |
| 1896 |
/* harmony import */ var _notifyManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./notifyManager.js */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 1897 |
/* harmony import */ var _query_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./query.js */ "./node_modules/@tanstack/query-core/build/modern/query.js"); |
| 1898 |
/* harmony import */ var _subscribable_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subscribable.js */ "./node_modules/@tanstack/query-core/build/modern/subscribable.js"); |
| 1899 |
/* harmony import */ var _thenable_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./thenable.js */ "./node_modules/@tanstack/query-core/build/modern/thenable.js"); |
| 1900 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 1901 |
/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); |
| 1902 |
// src/queryObserver.ts |
| 1903 |
|
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
var QueryObserver = class extends _subscribable_js__WEBPACK_IMPORTED_MODULE_3__.Subscribable { |
| 1911 |
constructor(client, options) { |
| 1912 |
super(); |
| 1913 |
this.options = options; |
| 1914 |
this.#client = client; |
| 1915 |
this.#selectError = null; |
| 1916 |
this.#currentThenable = (0,_thenable_js__WEBPACK_IMPORTED_MODULE_4__.pendingThenable)(); |
| 1917 |
this.bindMethods(); |
| 1918 |
this.setOptions(options); |
| 1919 |
} |
| 1920 |
#client; |
| 1921 |
#currentQuery = void 0; |
| 1922 |
#currentQueryInitialState = void 0; |
| 1923 |
#currentResult = void 0; |
| 1924 |
#currentResultState; |
| 1925 |
#currentResultOptions; |
| 1926 |
#currentThenable; |
| 1927 |
#selectError; |
| 1928 |
#selectFn; |
| 1929 |
#selectResult; |
| 1930 |
// This property keeps track of the last query with defined data. |
| 1931 |
// It will be used to pass the previous data and query to the placeholder function between renders. |
| 1932 |
#lastQueryWithDefinedData; |
| 1933 |
#staleTimeoutId; |
| 1934 |
#refetchIntervalId; |
| 1935 |
#currentRefetchInterval; |
| 1936 |
#trackedProps = /* @__PURE__ */ new Set(); |
| 1937 |
bindMethods() { |
| 1938 |
this.refetch = this.refetch.bind(this); |
| 1939 |
} |
| 1940 |
onSubscribe() { |
| 1941 |
if (this.listeners.size === 1) { |
| 1942 |
this.#currentQuery.addObserver(this); |
| 1943 |
if (shouldFetchOnMount(this.#currentQuery, this.options)) { |
| 1944 |
this.#executeFetch(); |
| 1945 |
} else { |
| 1946 |
this.updateResult(); |
| 1947 |
} |
| 1948 |
this.#updateTimers(); |
| 1949 |
} |
| 1950 |
} |
| 1951 |
onUnsubscribe() { |
| 1952 |
if (!this.hasListeners()) { |
| 1953 |
this.destroy(); |
| 1954 |
} |
| 1955 |
} |
| 1956 |
shouldFetchOnReconnect() { |
| 1957 |
return shouldFetchOn( |
| 1958 |
this.#currentQuery, |
| 1959 |
this.options, |
| 1960 |
this.options.refetchOnReconnect |
| 1961 |
); |
| 1962 |
} |
| 1963 |
shouldFetchOnWindowFocus() { |
| 1964 |
return shouldFetchOn( |
| 1965 |
this.#currentQuery, |
| 1966 |
this.options, |
| 1967 |
this.options.refetchOnWindowFocus |
| 1968 |
); |
| 1969 |
} |
| 1970 |
destroy() { |
| 1971 |
this.listeners = /* @__PURE__ */ new Set(); |
| 1972 |
this.#clearStaleTimeout(); |
| 1973 |
this.#clearRefetchInterval(); |
| 1974 |
this.#currentQuery.removeObserver(this); |
| 1975 |
} |
| 1976 |
setOptions(options) { |
| 1977 |
const prevOptions = this.options; |
| 1978 |
const prevQuery = this.#currentQuery; |
| 1979 |
this.options = this.#client.defaultQueryOptions(options); |
| 1980 |
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) !== "boolean") { |
| 1981 |
throw new Error( |
| 1982 |
"Expected enabled to be a boolean or a callback that returns a boolean" |
| 1983 |
); |
| 1984 |
} |
| 1985 |
this.#updateQuery(); |
| 1986 |
this.#currentQuery.setOptions(this.options); |
| 1987 |
if (prevOptions._defaulted && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.shallowEqualObjects)(this.options, prevOptions)) { |
| 1988 |
this.#client.getQueryCache().notify({ |
| 1989 |
type: "observerOptionsUpdated", |
| 1990 |
query: this.#currentQuery, |
| 1991 |
observer: this |
| 1992 |
}); |
| 1993 |
} |
| 1994 |
const mounted = this.hasListeners(); |
| 1995 |
if (mounted && shouldFetchOptionally( |
| 1996 |
this.#currentQuery, |
| 1997 |
prevQuery, |
| 1998 |
this.options, |
| 1999 |
prevOptions |
| 2000 |
)) { |
| 2001 |
this.#executeFetch(); |
| 2002 |
} |
| 2003 |
this.updateResult(); |
| 2004 |
if (mounted && (this.#currentQuery !== prevQuery || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(prevOptions.enabled, this.#currentQuery) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(this.options.staleTime, this.#currentQuery) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(prevOptions.staleTime, this.#currentQuery))) { |
| 2005 |
this.#updateStaleTimeout(); |
| 2006 |
} |
| 2007 |
const nextRefetchInterval = this.#computeRefetchInterval(); |
| 2008 |
if (mounted && (this.#currentQuery !== prevQuery || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) !== (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) { |
| 2009 |
this.#updateRefetchInterval(nextRefetchInterval); |
| 2010 |
} |
| 2011 |
} |
| 2012 |
getOptimisticResult(options) { |
| 2013 |
const query = this.#client.getQueryCache().build(this.#client, options); |
| 2014 |
const result = this.createResult(query, options); |
| 2015 |
if (shouldAssignObserverCurrentProperties(this, result)) { |
| 2016 |
this.#currentResult = result; |
| 2017 |
this.#currentResultOptions = this.options; |
| 2018 |
this.#currentResultState = this.#currentQuery.state; |
| 2019 |
} |
| 2020 |
return result; |
| 2021 |
} |
| 2022 |
getCurrentResult() { |
| 2023 |
return this.#currentResult; |
| 2024 |
} |
| 2025 |
trackResult(result, onPropTracked) { |
| 2026 |
return new Proxy(result, { |
| 2027 |
get: (target, key) => { |
| 2028 |
this.trackProp(key); |
| 2029 |
onPropTracked?.(key); |
| 2030 |
if (key === "promise") { |
| 2031 |
this.trackProp("data"); |
| 2032 |
if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") { |
| 2033 |
this.#currentThenable.reject( |
| 2034 |
new Error( |
| 2035 |
"experimental_prefetchInRender feature flag is not enabled" |
| 2036 |
) |
| 2037 |
); |
| 2038 |
} |
| 2039 |
} |
| 2040 |
return Reflect.get(target, key); |
| 2041 |
} |
| 2042 |
}); |
| 2043 |
} |
| 2044 |
trackProp(key) { |
| 2045 |
this.#trackedProps.add(key); |
| 2046 |
} |
| 2047 |
getCurrentQuery() { |
| 2048 |
return this.#currentQuery; |
| 2049 |
} |
| 2050 |
refetch({ ...options } = {}) { |
| 2051 |
return this.fetch({ |
| 2052 |
...options |
| 2053 |
}); |
| 2054 |
} |
| 2055 |
fetchOptimistic(options) { |
| 2056 |
const defaultedOptions = this.#client.defaultQueryOptions(options); |
| 2057 |
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions); |
| 2058 |
return query.fetch().then(() => this.createResult(query, defaultedOptions)); |
| 2059 |
} |
| 2060 |
fetch(fetchOptions) { |
| 2061 |
return this.#executeFetch({ |
| 2062 |
...fetchOptions, |
| 2063 |
cancelRefetch: fetchOptions.cancelRefetch ?? true |
| 2064 |
}).then(() => { |
| 2065 |
this.updateResult(); |
| 2066 |
return this.#currentResult; |
| 2067 |
}); |
| 2068 |
} |
| 2069 |
#executeFetch(fetchOptions) { |
| 2070 |
this.#updateQuery(); |
| 2071 |
let promise = this.#currentQuery.fetch( |
| 2072 |
this.options, |
| 2073 |
fetchOptions |
| 2074 |
); |
| 2075 |
if (!fetchOptions?.throwOnError) { |
| 2076 |
promise = promise.catch(_utils_js__WEBPACK_IMPORTED_MODULE_5__.noop); |
| 2077 |
} |
| 2078 |
return promise; |
| 2079 |
} |
| 2080 |
#updateStaleTimeout() { |
| 2081 |
this.#clearStaleTimeout(); |
| 2082 |
const staleTime = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)( |
| 2083 |
this.options.staleTime, |
| 2084 |
this.#currentQuery |
| 2085 |
); |
| 2086 |
if (_utils_js__WEBPACK_IMPORTED_MODULE_5__.isServer || this.#currentResult.isStale || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.isValidTimeout)(staleTime)) { |
| 2087 |
return; |
| 2088 |
} |
| 2089 |
const time = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.timeUntilStale)(this.#currentResult.dataUpdatedAt, staleTime); |
| 2090 |
const timeout = time + 1; |
| 2091 |
this.#staleTimeoutId = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.setTimeout(() => { |
| 2092 |
if (!this.#currentResult.isStale) { |
| 2093 |
this.updateResult(); |
| 2094 |
} |
| 2095 |
}, timeout); |
| 2096 |
} |
| 2097 |
#computeRefetchInterval() { |
| 2098 |
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false; |
| 2099 |
} |
| 2100 |
#updateRefetchInterval(nextInterval) { |
| 2101 |
this.#clearRefetchInterval(); |
| 2102 |
this.#currentRefetchInterval = nextInterval; |
| 2103 |
if (_utils_js__WEBPACK_IMPORTED_MODULE_5__.isServer || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(this.options.enabled, this.#currentQuery) === false || !(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.isValidTimeout)(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) { |
| 2104 |
return; |
| 2105 |
} |
| 2106 |
this.#refetchIntervalId = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.setInterval(() => { |
| 2107 |
if (this.options.refetchIntervalInBackground || _focusManager_js__WEBPACK_IMPORTED_MODULE_0__.focusManager.isFocused()) { |
| 2108 |
this.#executeFetch(); |
| 2109 |
} |
| 2110 |
}, this.#currentRefetchInterval); |
| 2111 |
} |
| 2112 |
#updateTimers() { |
| 2113 |
this.#updateStaleTimeout(); |
| 2114 |
this.#updateRefetchInterval(this.#computeRefetchInterval()); |
| 2115 |
} |
| 2116 |
#clearStaleTimeout() { |
| 2117 |
if (this.#staleTimeoutId) { |
| 2118 |
_timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.clearTimeout(this.#staleTimeoutId); |
| 2119 |
this.#staleTimeoutId = void 0; |
| 2120 |
} |
| 2121 |
} |
| 2122 |
#clearRefetchInterval() { |
| 2123 |
if (this.#refetchIntervalId) { |
| 2124 |
_timeoutManager_js__WEBPACK_IMPORTED_MODULE_6__.timeoutManager.clearInterval(this.#refetchIntervalId); |
| 2125 |
this.#refetchIntervalId = void 0; |
| 2126 |
} |
| 2127 |
} |
| 2128 |
createResult(query, options) { |
| 2129 |
const prevQuery = this.#currentQuery; |
| 2130 |
const prevOptions = this.options; |
| 2131 |
const prevResult = this.#currentResult; |
| 2132 |
const prevResultState = this.#currentResultState; |
| 2133 |
const prevResultOptions = this.#currentResultOptions; |
| 2134 |
const queryChange = query !== prevQuery; |
| 2135 |
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState; |
| 2136 |
const { state } = query; |
| 2137 |
let newState = { ...state }; |
| 2138 |
let isPlaceholderData = false; |
| 2139 |
let data; |
| 2140 |
if (options._optimisticResults) { |
| 2141 |
const mounted = this.hasListeners(); |
| 2142 |
const fetchOnMount = !mounted && shouldFetchOnMount(query, options); |
| 2143 |
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions); |
| 2144 |
if (fetchOnMount || fetchOptionally) { |
| 2145 |
newState = { |
| 2146 |
...newState, |
| 2147 |
...(0,_query_js__WEBPACK_IMPORTED_MODULE_2__.fetchState)(state.data, query.options) |
| 2148 |
}; |
| 2149 |
} |
| 2150 |
if (options._optimisticResults === "isRestoring") { |
| 2151 |
newState.fetchStatus = "idle"; |
| 2152 |
} |
| 2153 |
} |
| 2154 |
let { error, errorUpdatedAt, status } = newState; |
| 2155 |
data = newState.data; |
| 2156 |
let skipSelect = false; |
| 2157 |
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") { |
| 2158 |
let placeholderData; |
| 2159 |
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) { |
| 2160 |
placeholderData = prevResult.data; |
| 2161 |
skipSelect = true; |
| 2162 |
} else { |
| 2163 |
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData( |
| 2164 |
this.#lastQueryWithDefinedData?.state.data, |
| 2165 |
this.#lastQueryWithDefinedData |
| 2166 |
) : options.placeholderData; |
| 2167 |
} |
| 2168 |
if (placeholderData !== void 0) { |
| 2169 |
status = "success"; |
| 2170 |
data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.replaceData)( |
| 2171 |
prevResult?.data, |
| 2172 |
placeholderData, |
| 2173 |
options |
| 2174 |
); |
| 2175 |
isPlaceholderData = true; |
| 2176 |
} |
| 2177 |
} |
| 2178 |
if (options.select && data !== void 0 && !skipSelect) { |
| 2179 |
if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) { |
| 2180 |
data = this.#selectResult; |
| 2181 |
} else { |
| 2182 |
try { |
| 2183 |
this.#selectFn = options.select; |
| 2184 |
data = options.select(data); |
| 2185 |
data = (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.replaceData)(prevResult?.data, data, options); |
| 2186 |
this.#selectResult = data; |
| 2187 |
this.#selectError = null; |
| 2188 |
} catch (selectError) { |
| 2189 |
this.#selectError = selectError; |
| 2190 |
} |
| 2191 |
} |
| 2192 |
} |
| 2193 |
if (this.#selectError) { |
| 2194 |
error = this.#selectError; |
| 2195 |
data = this.#selectResult; |
| 2196 |
errorUpdatedAt = Date.now(); |
| 2197 |
status = "error"; |
| 2198 |
} |
| 2199 |
const isFetching = newState.fetchStatus === "fetching"; |
| 2200 |
const isPending = status === "pending"; |
| 2201 |
const isError = status === "error"; |
| 2202 |
const isLoading = isPending && isFetching; |
| 2203 |
const hasData = data !== void 0; |
| 2204 |
const result = { |
| 2205 |
status, |
| 2206 |
fetchStatus: newState.fetchStatus, |
| 2207 |
isPending, |
| 2208 |
isSuccess: status === "success", |
| 2209 |
isError, |
| 2210 |
isInitialLoading: isLoading, |
| 2211 |
isLoading, |
| 2212 |
data, |
| 2213 |
dataUpdatedAt: newState.dataUpdatedAt, |
| 2214 |
error, |
| 2215 |
errorUpdatedAt, |
| 2216 |
failureCount: newState.fetchFailureCount, |
| 2217 |
failureReason: newState.fetchFailureReason, |
| 2218 |
errorUpdateCount: newState.errorUpdateCount, |
| 2219 |
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0, |
| 2220 |
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount, |
| 2221 |
isFetching, |
| 2222 |
isRefetching: isFetching && !isPending, |
| 2223 |
isLoadingError: isError && !hasData, |
| 2224 |
isPaused: newState.fetchStatus === "paused", |
| 2225 |
isPlaceholderData, |
| 2226 |
isRefetchError: isError && hasData, |
| 2227 |
isStale: isStale(query, options), |
| 2228 |
refetch: this.refetch, |
| 2229 |
promise: this.#currentThenable, |
| 2230 |
isEnabled: (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false |
| 2231 |
}; |
| 2232 |
const nextResult = result; |
| 2233 |
if (this.options.experimental_prefetchInRender) { |
| 2234 |
const finalizeThenableIfPossible = (thenable) => { |
| 2235 |
if (nextResult.status === "error") { |
| 2236 |
thenable.reject(nextResult.error); |
| 2237 |
} else if (nextResult.data !== void 0) { |
| 2238 |
thenable.resolve(nextResult.data); |
| 2239 |
} |
| 2240 |
}; |
| 2241 |
const recreateThenable = () => { |
| 2242 |
const pending = this.#currentThenable = nextResult.promise = (0,_thenable_js__WEBPACK_IMPORTED_MODULE_4__.pendingThenable)(); |
| 2243 |
finalizeThenableIfPossible(pending); |
| 2244 |
}; |
| 2245 |
const prevThenable = this.#currentThenable; |
| 2246 |
switch (prevThenable.status) { |
| 2247 |
case "pending": |
| 2248 |
if (query.queryHash === prevQuery.queryHash) { |
| 2249 |
finalizeThenableIfPossible(prevThenable); |
| 2250 |
} |
| 2251 |
break; |
| 2252 |
case "fulfilled": |
| 2253 |
if (nextResult.status === "error" || nextResult.data !== prevThenable.value) { |
| 2254 |
recreateThenable(); |
| 2255 |
} |
| 2256 |
break; |
| 2257 |
case "rejected": |
| 2258 |
if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) { |
| 2259 |
recreateThenable(); |
| 2260 |
} |
| 2261 |
break; |
| 2262 |
} |
| 2263 |
} |
| 2264 |
return nextResult; |
| 2265 |
} |
| 2266 |
updateResult() { |
| 2267 |
const prevResult = this.#currentResult; |
| 2268 |
const nextResult = this.createResult(this.#currentQuery, this.options); |
| 2269 |
this.#currentResultState = this.#currentQuery.state; |
| 2270 |
this.#currentResultOptions = this.options; |
| 2271 |
if (this.#currentResultState.data !== void 0) { |
| 2272 |
this.#lastQueryWithDefinedData = this.#currentQuery; |
| 2273 |
} |
| 2274 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.shallowEqualObjects)(nextResult, prevResult)) { |
| 2275 |
return; |
| 2276 |
} |
| 2277 |
this.#currentResult = nextResult; |
| 2278 |
const shouldNotifyListeners = () => { |
| 2279 |
if (!prevResult) { |
| 2280 |
return true; |
| 2281 |
} |
| 2282 |
const { notifyOnChangeProps } = this.options; |
| 2283 |
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps; |
| 2284 |
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) { |
| 2285 |
return true; |
| 2286 |
} |
| 2287 |
const includedProps = new Set( |
| 2288 |
notifyOnChangePropsValue ?? this.#trackedProps |
| 2289 |
); |
| 2290 |
if (this.options.throwOnError) { |
| 2291 |
includedProps.add("error"); |
| 2292 |
} |
| 2293 |
return Object.keys(this.#currentResult).some((key) => { |
| 2294 |
const typedKey = key; |
| 2295 |
const changed = this.#currentResult[typedKey] !== prevResult[typedKey]; |
| 2296 |
return changed && includedProps.has(typedKey); |
| 2297 |
}); |
| 2298 |
}; |
| 2299 |
this.#notify({ listeners: shouldNotifyListeners() }); |
| 2300 |
} |
| 2301 |
#updateQuery() { |
| 2302 |
const query = this.#client.getQueryCache().build(this.#client, this.options); |
| 2303 |
if (query === this.#currentQuery) { |
| 2304 |
return; |
| 2305 |
} |
| 2306 |
const prevQuery = this.#currentQuery; |
| 2307 |
this.#currentQuery = query; |
| 2308 |
this.#currentQueryInitialState = query.state; |
| 2309 |
if (this.hasListeners()) { |
| 2310 |
prevQuery?.removeObserver(this); |
| 2311 |
query.addObserver(this); |
| 2312 |
} |
| 2313 |
} |
| 2314 |
onQueryUpdate() { |
| 2315 |
this.updateResult(); |
| 2316 |
if (this.hasListeners()) { |
| 2317 |
this.#updateTimers(); |
| 2318 |
} |
| 2319 |
} |
| 2320 |
#notify(notifyOptions) { |
| 2321 |
_notifyManager_js__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batch(() => { |
| 2322 |
if (notifyOptions.listeners) { |
| 2323 |
this.listeners.forEach((listener) => { |
| 2324 |
listener(this.#currentResult); |
| 2325 |
}); |
| 2326 |
} |
| 2327 |
this.#client.getQueryCache().notify({ |
| 2328 |
query: this.#currentQuery, |
| 2329 |
type: "observerResultsUpdated" |
| 2330 |
}); |
| 2331 |
}); |
| 2332 |
} |
| 2333 |
}; |
| 2334 |
function shouldLoadOnMount(query, options) { |
| 2335 |
return (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false); |
| 2336 |
} |
| 2337 |
function shouldFetchOnMount(query, options) { |
| 2338 |
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount); |
| 2339 |
} |
| 2340 |
function shouldFetchOn(query, options, field) { |
| 2341 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false && (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(options.staleTime, query) !== "static") { |
| 2342 |
const value = typeof field === "function" ? field(query) : field; |
| 2343 |
return value === "always" || value !== false && isStale(query, options); |
| 2344 |
} |
| 2345 |
return false; |
| 2346 |
} |
| 2347 |
function shouldFetchOptionally(query, prevQuery, options, prevOptions) { |
| 2348 |
return (query !== prevQuery || (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); |
| 2349 |
} |
| 2350 |
function isStale(query, options) { |
| 2351 |
return (0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveEnabled)(options.enabled, query) !== false && query.isStaleByTime((0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.resolveStaleTime)(options.staleTime, query)); |
| 2352 |
} |
| 2353 |
function shouldAssignObserverCurrentProperties(observer, optimisticResult) { |
| 2354 |
if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_5__.shallowEqualObjects)(observer.getCurrentResult(), optimisticResult)) { |
| 2355 |
return true; |
| 2356 |
} |
| 2357 |
return false; |
| 2358 |
} |
| 2359 |
|
| 2360 |
//# sourceMappingURL=queryObserver.js.map |
| 2361 |
|
| 2362 |
/***/ }), |
| 2363 |
|
| 2364 |
/***/ "./node_modules/@tanstack/query-core/build/modern/removable.js": |
| 2365 |
/*!*********************************************************************!*\ |
| 2366 |
!*** ./node_modules/@tanstack/query-core/build/modern/removable.js ***! |
| 2367 |
\*********************************************************************/ |
| 2368 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2369 |
|
| 2370 |
__webpack_require__.r(__webpack_exports__); |
| 2371 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2372 |
/* harmony export */ Removable: function() { return /* binding */ Removable; } |
| 2373 |
/* harmony export */ }); |
| 2374 |
/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); |
| 2375 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 2376 |
// src/removable.ts |
| 2377 |
|
| 2378 |
|
| 2379 |
var Removable = class { |
| 2380 |
#gcTimeout; |
| 2381 |
destroy() { |
| 2382 |
this.clearGcTimeout(); |
| 2383 |
} |
| 2384 |
scheduleGc() { |
| 2385 |
this.clearGcTimeout(); |
| 2386 |
if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isValidTimeout)(this.gcTime)) { |
| 2387 |
this.#gcTimeout = _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.timeoutManager.setTimeout(() => { |
| 2388 |
this.optionalRemove(); |
| 2389 |
}, this.gcTime); |
| 2390 |
} |
| 2391 |
} |
| 2392 |
updateGcTime(newGcTime) { |
| 2393 |
this.gcTime = Math.max( |
| 2394 |
this.gcTime || 0, |
| 2395 |
newGcTime ?? (_utils_js__WEBPACK_IMPORTED_MODULE_1__.isServer ? Infinity : 5 * 60 * 1e3) |
| 2396 |
); |
| 2397 |
} |
| 2398 |
clearGcTimeout() { |
| 2399 |
if (this.#gcTimeout) { |
| 2400 |
_timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.timeoutManager.clearTimeout(this.#gcTimeout); |
| 2401 |
this.#gcTimeout = void 0; |
| 2402 |
} |
| 2403 |
} |
| 2404 |
}; |
| 2405 |
|
| 2406 |
//# sourceMappingURL=removable.js.map |
| 2407 |
|
| 2408 |
/***/ }), |
| 2409 |
|
| 2410 |
/***/ "./node_modules/@tanstack/query-core/build/modern/retryer.js": |
| 2411 |
/*!*******************************************************************!*\ |
| 2412 |
!*** ./node_modules/@tanstack/query-core/build/modern/retryer.js ***! |
| 2413 |
\*******************************************************************/ |
| 2414 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2415 |
|
| 2416 |
__webpack_require__.r(__webpack_exports__); |
| 2417 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2418 |
/* harmony export */ CancelledError: function() { return /* binding */ CancelledError; }, |
| 2419 |
/* harmony export */ canFetch: function() { return /* binding */ canFetch; }, |
| 2420 |
/* harmony export */ createRetryer: function() { return /* binding */ createRetryer; }, |
| 2421 |
/* harmony export */ isCancelledError: function() { return /* binding */ isCancelledError; } |
| 2422 |
/* harmony export */ }); |
| 2423 |
/* harmony import */ var _focusManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focusManager.js */ "./node_modules/@tanstack/query-core/build/modern/focusManager.js"); |
| 2424 |
/* harmony import */ var _onlineManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./onlineManager.js */ "./node_modules/@tanstack/query-core/build/modern/onlineManager.js"); |
| 2425 |
/* harmony import */ var _thenable_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./thenable.js */ "./node_modules/@tanstack/query-core/build/modern/thenable.js"); |
| 2426 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 2427 |
// src/retryer.ts |
| 2428 |
|
| 2429 |
|
| 2430 |
|
| 2431 |
|
| 2432 |
function defaultRetryDelay(failureCount) { |
| 2433 |
return Math.min(1e3 * 2 ** failureCount, 3e4); |
| 2434 |
} |
| 2435 |
function canFetch(networkMode) { |
| 2436 |
return (networkMode ?? "online") === "online" ? _onlineManager_js__WEBPACK_IMPORTED_MODULE_1__.onlineManager.isOnline() : true; |
| 2437 |
} |
| 2438 |
var CancelledError = class extends Error { |
| 2439 |
constructor(options) { |
| 2440 |
super("CancelledError"); |
| 2441 |
this.revert = options?.revert; |
| 2442 |
this.silent = options?.silent; |
| 2443 |
} |
| 2444 |
}; |
| 2445 |
function isCancelledError(value) { |
| 2446 |
return value instanceof CancelledError; |
| 2447 |
} |
| 2448 |
function createRetryer(config) { |
| 2449 |
let isRetryCancelled = false; |
| 2450 |
let failureCount = 0; |
| 2451 |
let continueFn; |
| 2452 |
const thenable = (0,_thenable_js__WEBPACK_IMPORTED_MODULE_2__.pendingThenable)(); |
| 2453 |
const isResolved = () => thenable.status !== "pending"; |
| 2454 |
const cancel = (cancelOptions) => { |
| 2455 |
if (!isResolved()) { |
| 2456 |
const error = new CancelledError(cancelOptions); |
| 2457 |
reject(error); |
| 2458 |
config.onCancel?.(error); |
| 2459 |
} |
| 2460 |
}; |
| 2461 |
const cancelRetry = () => { |
| 2462 |
isRetryCancelled = true; |
| 2463 |
}; |
| 2464 |
const continueRetry = () => { |
| 2465 |
isRetryCancelled = false; |
| 2466 |
}; |
| 2467 |
const canContinue = () => _focusManager_js__WEBPACK_IMPORTED_MODULE_0__.focusManager.isFocused() && (config.networkMode === "always" || _onlineManager_js__WEBPACK_IMPORTED_MODULE_1__.onlineManager.isOnline()) && config.canRun(); |
| 2468 |
const canStart = () => canFetch(config.networkMode) && config.canRun(); |
| 2469 |
const resolve = (value) => { |
| 2470 |
if (!isResolved()) { |
| 2471 |
continueFn?.(); |
| 2472 |
thenable.resolve(value); |
| 2473 |
} |
| 2474 |
}; |
| 2475 |
const reject = (value) => { |
| 2476 |
if (!isResolved()) { |
| 2477 |
continueFn?.(); |
| 2478 |
thenable.reject(value); |
| 2479 |
} |
| 2480 |
}; |
| 2481 |
const pause = () => { |
| 2482 |
return new Promise((continueResolve) => { |
| 2483 |
continueFn = (value) => { |
| 2484 |
if (isResolved() || canContinue()) { |
| 2485 |
continueResolve(value); |
| 2486 |
} |
| 2487 |
}; |
| 2488 |
config.onPause?.(); |
| 2489 |
}).then(() => { |
| 2490 |
continueFn = void 0; |
| 2491 |
if (!isResolved()) { |
| 2492 |
config.onContinue?.(); |
| 2493 |
} |
| 2494 |
}); |
| 2495 |
}; |
| 2496 |
const run = () => { |
| 2497 |
if (isResolved()) { |
| 2498 |
return; |
| 2499 |
} |
| 2500 |
let promiseOrValue; |
| 2501 |
const initialPromise = failureCount === 0 ? config.initialPromise : void 0; |
| 2502 |
try { |
| 2503 |
promiseOrValue = initialPromise ?? config.fn(); |
| 2504 |
} catch (error) { |
| 2505 |
promiseOrValue = Promise.reject(error); |
| 2506 |
} |
| 2507 |
Promise.resolve(promiseOrValue).then(resolve).catch((error) => { |
| 2508 |
if (isResolved()) { |
| 2509 |
return; |
| 2510 |
} |
| 2511 |
const retry = config.retry ?? (_utils_js__WEBPACK_IMPORTED_MODULE_3__.isServer ? 0 : 3); |
| 2512 |
const retryDelay = config.retryDelay ?? defaultRetryDelay; |
| 2513 |
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay; |
| 2514 |
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error); |
| 2515 |
if (isRetryCancelled || !shouldRetry) { |
| 2516 |
reject(error); |
| 2517 |
return; |
| 2518 |
} |
| 2519 |
failureCount++; |
| 2520 |
config.onFail?.(failureCount, error); |
| 2521 |
(0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.sleep)(delay).then(() => { |
| 2522 |
return canContinue() ? void 0 : pause(); |
| 2523 |
}).then(() => { |
| 2524 |
if (isRetryCancelled) { |
| 2525 |
reject(error); |
| 2526 |
} else { |
| 2527 |
run(); |
| 2528 |
} |
| 2529 |
}); |
| 2530 |
}); |
| 2531 |
}; |
| 2532 |
return { |
| 2533 |
promise: thenable, |
| 2534 |
status: () => thenable.status, |
| 2535 |
cancel, |
| 2536 |
continue: () => { |
| 2537 |
continueFn?.(); |
| 2538 |
return thenable; |
| 2539 |
}, |
| 2540 |
cancelRetry, |
| 2541 |
continueRetry, |
| 2542 |
canStart, |
| 2543 |
start: () => { |
| 2544 |
if (canStart()) { |
| 2545 |
run(); |
| 2546 |
} else { |
| 2547 |
pause().then(run); |
| 2548 |
} |
| 2549 |
return thenable; |
| 2550 |
} |
| 2551 |
}; |
| 2552 |
} |
| 2553 |
|
| 2554 |
//# sourceMappingURL=retryer.js.map |
| 2555 |
|
| 2556 |
/***/ }), |
| 2557 |
|
| 2558 |
/***/ "./node_modules/@tanstack/query-core/build/modern/subscribable.js": |
| 2559 |
/*!************************************************************************!*\ |
| 2560 |
!*** ./node_modules/@tanstack/query-core/build/modern/subscribable.js ***! |
| 2561 |
\************************************************************************/ |
| 2562 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2563 |
|
| 2564 |
__webpack_require__.r(__webpack_exports__); |
| 2565 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2566 |
/* harmony export */ Subscribable: function() { return /* binding */ Subscribable; } |
| 2567 |
/* harmony export */ }); |
| 2568 |
// src/subscribable.ts |
| 2569 |
var Subscribable = class { |
| 2570 |
constructor() { |
| 2571 |
this.listeners = /* @__PURE__ */ new Set(); |
| 2572 |
this.subscribe = this.subscribe.bind(this); |
| 2573 |
} |
| 2574 |
subscribe(listener) { |
| 2575 |
this.listeners.add(listener); |
| 2576 |
this.onSubscribe(); |
| 2577 |
return () => { |
| 2578 |
this.listeners.delete(listener); |
| 2579 |
this.onUnsubscribe(); |
| 2580 |
}; |
| 2581 |
} |
| 2582 |
hasListeners() { |
| 2583 |
return this.listeners.size > 0; |
| 2584 |
} |
| 2585 |
onSubscribe() { |
| 2586 |
} |
| 2587 |
onUnsubscribe() { |
| 2588 |
} |
| 2589 |
}; |
| 2590 |
|
| 2591 |
//# sourceMappingURL=subscribable.js.map |
| 2592 |
|
| 2593 |
/***/ }), |
| 2594 |
|
| 2595 |
/***/ "./node_modules/@tanstack/query-core/build/modern/thenable.js": |
| 2596 |
/*!********************************************************************!*\ |
| 2597 |
!*** ./node_modules/@tanstack/query-core/build/modern/thenable.js ***! |
| 2598 |
\********************************************************************/ |
| 2599 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2600 |
|
| 2601 |
__webpack_require__.r(__webpack_exports__); |
| 2602 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2603 |
/* harmony export */ pendingThenable: function() { return /* binding */ pendingThenable; }, |
| 2604 |
/* harmony export */ tryResolveSync: function() { return /* binding */ tryResolveSync; } |
| 2605 |
/* harmony export */ }); |
| 2606 |
/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 2607 |
// src/thenable.ts |
| 2608 |
|
| 2609 |
function pendingThenable() { |
| 2610 |
let resolve; |
| 2611 |
let reject; |
| 2612 |
const thenable = new Promise((_resolve, _reject) => { |
| 2613 |
resolve = _resolve; |
| 2614 |
reject = _reject; |
| 2615 |
}); |
| 2616 |
thenable.status = "pending"; |
| 2617 |
thenable.catch(() => { |
| 2618 |
}); |
| 2619 |
function finalize(data) { |
| 2620 |
Object.assign(thenable, data); |
| 2621 |
delete thenable.resolve; |
| 2622 |
delete thenable.reject; |
| 2623 |
} |
| 2624 |
thenable.resolve = (value) => { |
| 2625 |
finalize({ |
| 2626 |
status: "fulfilled", |
| 2627 |
value |
| 2628 |
}); |
| 2629 |
resolve(value); |
| 2630 |
}; |
| 2631 |
thenable.reject = (reason) => { |
| 2632 |
finalize({ |
| 2633 |
status: "rejected", |
| 2634 |
reason |
| 2635 |
}); |
| 2636 |
reject(reason); |
| 2637 |
}; |
| 2638 |
return thenable; |
| 2639 |
} |
| 2640 |
function tryResolveSync(promise) { |
| 2641 |
let data; |
| 2642 |
promise.then((result) => { |
| 2643 |
data = result; |
| 2644 |
return result; |
| 2645 |
}, _utils_js__WEBPACK_IMPORTED_MODULE_0__.noop)?.catch(_utils_js__WEBPACK_IMPORTED_MODULE_0__.noop); |
| 2646 |
if (data !== void 0) { |
| 2647 |
return { data }; |
| 2648 |
} |
| 2649 |
return void 0; |
| 2650 |
} |
| 2651 |
|
| 2652 |
//# sourceMappingURL=thenable.js.map |
| 2653 |
|
| 2654 |
/***/ }), |
| 2655 |
|
| 2656 |
/***/ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js": |
| 2657 |
/*!**************************************************************************!*\ |
| 2658 |
!*** ./node_modules/@tanstack/query-core/build/modern/timeoutManager.js ***! |
| 2659 |
\**************************************************************************/ |
| 2660 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2661 |
|
| 2662 |
__webpack_require__.r(__webpack_exports__); |
| 2663 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2664 |
/* harmony export */ TimeoutManager: function() { return /* binding */ TimeoutManager; }, |
| 2665 |
/* harmony export */ defaultTimeoutProvider: function() { return /* binding */ defaultTimeoutProvider; }, |
| 2666 |
/* harmony export */ systemSetTimeoutZero: function() { return /* binding */ systemSetTimeoutZero; }, |
| 2667 |
/* harmony export */ timeoutManager: function() { return /* binding */ timeoutManager; } |
| 2668 |
/* harmony export */ }); |
| 2669 |
// src/timeoutManager.ts |
| 2670 |
var defaultTimeoutProvider = { |
| 2671 |
// We need the wrapper function syntax below instead of direct references to |
| 2672 |
// global setTimeout etc. |
| 2673 |
// |
| 2674 |
// BAD: `setTimeout: setTimeout` |
| 2675 |
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)` |
| 2676 |
// |
| 2677 |
// If we use direct references here, then anything that wants to spy on or |
| 2678 |
// replace the global setTimeout (like tests) won't work since we'll already |
| 2679 |
// have a hard reference to the original implementation at the time when this |
| 2680 |
// file was imported. |
| 2681 |
setTimeout: (callback, delay) => setTimeout(callback, delay), |
| 2682 |
clearTimeout: (timeoutId) => clearTimeout(timeoutId), |
| 2683 |
setInterval: (callback, delay) => setInterval(callback, delay), |
| 2684 |
clearInterval: (intervalId) => clearInterval(intervalId) |
| 2685 |
}; |
| 2686 |
var TimeoutManager = class { |
| 2687 |
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete |
| 2688 |
// type at app boot; and if we leave that type, then any new timer provider |
| 2689 |
// would need to support ReturnType<typeof setTimeout>, which is infeasible. |
| 2690 |
// |
| 2691 |
// We settle for type safety for the TimeoutProvider type, and accept that |
| 2692 |
// this class is unsafe internally to allow for extension. |
| 2693 |
#provider = defaultTimeoutProvider; |
| 2694 |
#providerCalled = false; |
| 2695 |
setTimeoutProvider(provider) { |
| 2696 |
if (true) { |
| 2697 |
if (this.#providerCalled && provider !== this.#provider) { |
| 2698 |
console.error( |
| 2699 |
`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`, |
| 2700 |
{ previous: this.#provider, provider } |
| 2701 |
); |
| 2702 |
} |
| 2703 |
} |
| 2704 |
this.#provider = provider; |
| 2705 |
if (true) { |
| 2706 |
this.#providerCalled = false; |
| 2707 |
} |
| 2708 |
} |
| 2709 |
setTimeout(callback, delay) { |
| 2710 |
if (true) { |
| 2711 |
this.#providerCalled = true; |
| 2712 |
} |
| 2713 |
return this.#provider.setTimeout(callback, delay); |
| 2714 |
} |
| 2715 |
clearTimeout(timeoutId) { |
| 2716 |
this.#provider.clearTimeout(timeoutId); |
| 2717 |
} |
| 2718 |
setInterval(callback, delay) { |
| 2719 |
if (true) { |
| 2720 |
this.#providerCalled = true; |
| 2721 |
} |
| 2722 |
return this.#provider.setInterval(callback, delay); |
| 2723 |
} |
| 2724 |
clearInterval(intervalId) { |
| 2725 |
this.#provider.clearInterval(intervalId); |
| 2726 |
} |
| 2727 |
}; |
| 2728 |
var timeoutManager = new TimeoutManager(); |
| 2729 |
function systemSetTimeoutZero(callback) { |
| 2730 |
setTimeout(callback, 0); |
| 2731 |
} |
| 2732 |
|
| 2733 |
//# sourceMappingURL=timeoutManager.js.map |
| 2734 |
|
| 2735 |
/***/ }), |
| 2736 |
|
| 2737 |
/***/ "./node_modules/@tanstack/query-core/build/modern/utils.js": |
| 2738 |
/*!*****************************************************************!*\ |
| 2739 |
!*** ./node_modules/@tanstack/query-core/build/modern/utils.js ***! |
| 2740 |
\*****************************************************************/ |
| 2741 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 2742 |
|
| 2743 |
__webpack_require__.r(__webpack_exports__); |
| 2744 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2745 |
/* harmony export */ addConsumeAwareSignal: function() { return /* binding */ addConsumeAwareSignal; }, |
| 2746 |
/* harmony export */ addToEnd: function() { return /* binding */ addToEnd; }, |
| 2747 |
/* harmony export */ addToStart: function() { return /* binding */ addToStart; }, |
| 2748 |
/* harmony export */ ensureQueryFn: function() { return /* binding */ ensureQueryFn; }, |
| 2749 |
/* harmony export */ functionalUpdate: function() { return /* binding */ functionalUpdate; }, |
| 2750 |
/* harmony export */ hashKey: function() { return /* binding */ hashKey; }, |
| 2751 |
/* harmony export */ hashQueryKeyByOptions: function() { return /* binding */ hashQueryKeyByOptions; }, |
| 2752 |
/* harmony export */ isPlainArray: function() { return /* binding */ isPlainArray; }, |
| 2753 |
/* harmony export */ isPlainObject: function() { return /* binding */ isPlainObject; }, |
| 2754 |
/* harmony export */ isServer: function() { return /* binding */ isServer; }, |
| 2755 |
/* harmony export */ isValidTimeout: function() { return /* binding */ isValidTimeout; }, |
| 2756 |
/* harmony export */ keepPreviousData: function() { return /* binding */ keepPreviousData; }, |
| 2757 |
/* harmony export */ matchMutation: function() { return /* binding */ matchMutation; }, |
| 2758 |
/* harmony export */ matchQuery: function() { return /* binding */ matchQuery; }, |
| 2759 |
/* harmony export */ noop: function() { return /* binding */ noop; }, |
| 2760 |
/* harmony export */ partialMatchKey: function() { return /* binding */ partialMatchKey; }, |
| 2761 |
/* harmony export */ replaceData: function() { return /* binding */ replaceData; }, |
| 2762 |
/* harmony export */ replaceEqualDeep: function() { return /* binding */ replaceEqualDeep; }, |
| 2763 |
/* harmony export */ resolveEnabled: function() { return /* binding */ resolveEnabled; }, |
| 2764 |
/* harmony export */ resolveStaleTime: function() { return /* binding */ resolveStaleTime; }, |
| 2765 |
/* harmony export */ shallowEqualObjects: function() { return /* binding */ shallowEqualObjects; }, |
| 2766 |
/* harmony export */ shouldThrowError: function() { return /* binding */ shouldThrowError; }, |
| 2767 |
/* harmony export */ skipToken: function() { return /* binding */ skipToken; }, |
| 2768 |
/* harmony export */ sleep: function() { return /* binding */ sleep; }, |
| 2769 |
/* harmony export */ timeUntilStale: function() { return /* binding */ timeUntilStale; } |
| 2770 |
/* harmony export */ }); |
| 2771 |
/* harmony import */ var _timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timeoutManager.js */ "./node_modules/@tanstack/query-core/build/modern/timeoutManager.js"); |
| 2772 |
// src/utils.ts |
| 2773 |
|
| 2774 |
var isServer = typeof window === "undefined" || "Deno" in globalThis; |
| 2775 |
function noop() { |
| 2776 |
} |
| 2777 |
function functionalUpdate(updater, input) { |
| 2778 |
return typeof updater === "function" ? updater(input) : updater; |
| 2779 |
} |
| 2780 |
function isValidTimeout(value) { |
| 2781 |
return typeof value === "number" && value >= 0 && value !== Infinity; |
| 2782 |
} |
| 2783 |
function timeUntilStale(updatedAt, staleTime) { |
| 2784 |
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); |
| 2785 |
} |
| 2786 |
function resolveStaleTime(staleTime, query) { |
| 2787 |
return typeof staleTime === "function" ? staleTime(query) : staleTime; |
| 2788 |
} |
| 2789 |
function resolveEnabled(enabled, query) { |
| 2790 |
return typeof enabled === "function" ? enabled(query) : enabled; |
| 2791 |
} |
| 2792 |
function matchQuery(filters, query) { |
| 2793 |
const { |
| 2794 |
type = "all", |
| 2795 |
exact, |
| 2796 |
fetchStatus, |
| 2797 |
predicate, |
| 2798 |
queryKey, |
| 2799 |
stale |
| 2800 |
} = filters; |
| 2801 |
if (queryKey) { |
| 2802 |
if (exact) { |
| 2803 |
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) { |
| 2804 |
return false; |
| 2805 |
} |
| 2806 |
} else if (!partialMatchKey(query.queryKey, queryKey)) { |
| 2807 |
return false; |
| 2808 |
} |
| 2809 |
} |
| 2810 |
if (type !== "all") { |
| 2811 |
const isActive = query.isActive(); |
| 2812 |
if (type === "active" && !isActive) { |
| 2813 |
return false; |
| 2814 |
} |
| 2815 |
if (type === "inactive" && isActive) { |
| 2816 |
return false; |
| 2817 |
} |
| 2818 |
} |
| 2819 |
if (typeof stale === "boolean" && query.isStale() !== stale) { |
| 2820 |
return false; |
| 2821 |
} |
| 2822 |
if (fetchStatus && fetchStatus !== query.state.fetchStatus) { |
| 2823 |
return false; |
| 2824 |
} |
| 2825 |
if (predicate && !predicate(query)) { |
| 2826 |
return false; |
| 2827 |
} |
| 2828 |
return true; |
| 2829 |
} |
| 2830 |
function matchMutation(filters, mutation) { |
| 2831 |
const { exact, status, predicate, mutationKey } = filters; |
| 2832 |
if (mutationKey) { |
| 2833 |
if (!mutation.options.mutationKey) { |
| 2834 |
return false; |
| 2835 |
} |
| 2836 |
if (exact) { |
| 2837 |
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) { |
| 2838 |
return false; |
| 2839 |
} |
| 2840 |
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) { |
| 2841 |
return false; |
| 2842 |
} |
| 2843 |
} |
| 2844 |
if (status && mutation.state.status !== status) { |
| 2845 |
return false; |
| 2846 |
} |
| 2847 |
if (predicate && !predicate(mutation)) { |
| 2848 |
return false; |
| 2849 |
} |
| 2850 |
return true; |
| 2851 |
} |
| 2852 |
function hashQueryKeyByOptions(queryKey, options) { |
| 2853 |
const hashFn = options?.queryKeyHashFn || hashKey; |
| 2854 |
return hashFn(queryKey); |
| 2855 |
} |
| 2856 |
function hashKey(queryKey) { |
| 2857 |
return JSON.stringify( |
| 2858 |
queryKey, |
| 2859 |
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => { |
| 2860 |
result[key] = val[key]; |
| 2861 |
return result; |
| 2862 |
}, {}) : val |
| 2863 |
); |
| 2864 |
} |
| 2865 |
function partialMatchKey(a, b) { |
| 2866 |
if (a === b) { |
| 2867 |
return true; |
| 2868 |
} |
| 2869 |
if (typeof a !== typeof b) { |
| 2870 |
return false; |
| 2871 |
} |
| 2872 |
if (a && b && typeof a === "object" && typeof b === "object") { |
| 2873 |
return Object.keys(b).every((key) => partialMatchKey(a[key], b[key])); |
| 2874 |
} |
| 2875 |
return false; |
| 2876 |
} |
| 2877 |
var hasOwn = Object.prototype.hasOwnProperty; |
| 2878 |
function replaceEqualDeep(a, b) { |
| 2879 |
if (a === b) { |
| 2880 |
return a; |
| 2881 |
} |
| 2882 |
const array = isPlainArray(a) && isPlainArray(b); |
| 2883 |
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b; |
| 2884 |
const aItems = array ? a : Object.keys(a); |
| 2885 |
const aSize = aItems.length; |
| 2886 |
const bItems = array ? b : Object.keys(b); |
| 2887 |
const bSize = bItems.length; |
| 2888 |
const copy = array ? new Array(bSize) : {}; |
| 2889 |
let equalItems = 0; |
| 2890 |
for (let i = 0; i < bSize; i++) { |
| 2891 |
const key = array ? i : bItems[i]; |
| 2892 |
const aItem = a[key]; |
| 2893 |
const bItem = b[key]; |
| 2894 |
if (aItem === bItem) { |
| 2895 |
copy[key] = aItem; |
| 2896 |
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++; |
| 2897 |
continue; |
| 2898 |
} |
| 2899 |
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") { |
| 2900 |
copy[key] = bItem; |
| 2901 |
continue; |
| 2902 |
} |
| 2903 |
const v = replaceEqualDeep(aItem, bItem); |
| 2904 |
copy[key] = v; |
| 2905 |
if (v === aItem) equalItems++; |
| 2906 |
} |
| 2907 |
return aSize === bSize && equalItems === aSize ? a : copy; |
| 2908 |
} |
| 2909 |
function shallowEqualObjects(a, b) { |
| 2910 |
if (!b || Object.keys(a).length !== Object.keys(b).length) { |
| 2911 |
return false; |
| 2912 |
} |
| 2913 |
for (const key in a) { |
| 2914 |
if (a[key] !== b[key]) { |
| 2915 |
return false; |
| 2916 |
} |
| 2917 |
} |
| 2918 |
return true; |
| 2919 |
} |
| 2920 |
function isPlainArray(value) { |
| 2921 |
return Array.isArray(value) && value.length === Object.keys(value).length; |
| 2922 |
} |
| 2923 |
function isPlainObject(o) { |
| 2924 |
if (!hasObjectPrototype(o)) { |
| 2925 |
return false; |
| 2926 |
} |
| 2927 |
const ctor = o.constructor; |
| 2928 |
if (ctor === void 0) { |
| 2929 |
return true; |
| 2930 |
} |
| 2931 |
const prot = ctor.prototype; |
| 2932 |
if (!hasObjectPrototype(prot)) { |
| 2933 |
return false; |
| 2934 |
} |
| 2935 |
if (!prot.hasOwnProperty("isPrototypeOf")) { |
| 2936 |
return false; |
| 2937 |
} |
| 2938 |
if (Object.getPrototypeOf(o) !== Object.prototype) { |
| 2939 |
return false; |
| 2940 |
} |
| 2941 |
return true; |
| 2942 |
} |
| 2943 |
function hasObjectPrototype(o) { |
| 2944 |
return Object.prototype.toString.call(o) === "[object Object]"; |
| 2945 |
} |
| 2946 |
function sleep(timeout) { |
| 2947 |
return new Promise((resolve) => { |
| 2948 |
_timeoutManager_js__WEBPACK_IMPORTED_MODULE_0__.timeoutManager.setTimeout(resolve, timeout); |
| 2949 |
}); |
| 2950 |
} |
| 2951 |
function replaceData(prevData, data, options) { |
| 2952 |
if (typeof options.structuralSharing === "function") { |
| 2953 |
return options.structuralSharing(prevData, data); |
| 2954 |
} else if (options.structuralSharing !== false) { |
| 2955 |
if (true) { |
| 2956 |
try { |
| 2957 |
return replaceEqualDeep(prevData, data); |
| 2958 |
} catch (error) { |
| 2959 |
console.error( |
| 2960 |
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}` |
| 2961 |
); |
| 2962 |
throw error; |
| 2963 |
} |
| 2964 |
} |
| 2965 |
// removed by dead control flow |
| 2966 |
|
| 2967 |
} |
| 2968 |
return data; |
| 2969 |
} |
| 2970 |
function keepPreviousData(previousData) { |
| 2971 |
return previousData; |
| 2972 |
} |
| 2973 |
function addToEnd(items, item, max = 0) { |
| 2974 |
const newItems = [...items, item]; |
| 2975 |
return max && newItems.length > max ? newItems.slice(1) : newItems; |
| 2976 |
} |
| 2977 |
function addToStart(items, item, max = 0) { |
| 2978 |
const newItems = [item, ...items]; |
| 2979 |
return max && newItems.length > max ? newItems.slice(0, -1) : newItems; |
| 2980 |
} |
| 2981 |
var skipToken = Symbol(); |
| 2982 |
function ensureQueryFn(options, fetchOptions) { |
| 2983 |
if (true) { |
| 2984 |
if (options.queryFn === skipToken) { |
| 2985 |
console.error( |
| 2986 |
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'` |
| 2987 |
); |
| 2988 |
} |
| 2989 |
} |
| 2990 |
if (!options.queryFn && fetchOptions?.initialPromise) { |
| 2991 |
return () => fetchOptions.initialPromise; |
| 2992 |
} |
| 2993 |
if (!options.queryFn || options.queryFn === skipToken) { |
| 2994 |
return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`)); |
| 2995 |
} |
| 2996 |
return options.queryFn; |
| 2997 |
} |
| 2998 |
function shouldThrowError(throwOnError, params) { |
| 2999 |
if (typeof throwOnError === "function") { |
| 3000 |
return throwOnError(...params); |
| 3001 |
} |
| 3002 |
return !!throwOnError; |
| 3003 |
} |
| 3004 |
function addConsumeAwareSignal(object, getSignal, onCancelled) { |
| 3005 |
let consumed = false; |
| 3006 |
let signal; |
| 3007 |
Object.defineProperty(object, "signal", { |
| 3008 |
enumerable: true, |
| 3009 |
get: () => { |
| 3010 |
signal ??= getSignal(); |
| 3011 |
if (consumed) { |
| 3012 |
return signal; |
| 3013 |
} |
| 3014 |
consumed = true; |
| 3015 |
if (signal.aborted) { |
| 3016 |
onCancelled(); |
| 3017 |
} else { |
| 3018 |
signal.addEventListener("abort", onCancelled, { once: true }); |
| 3019 |
} |
| 3020 |
return signal; |
| 3021 |
} |
| 3022 |
}); |
| 3023 |
return object; |
| 3024 |
} |
| 3025 |
|
| 3026 |
//# sourceMappingURL=utils.js.map |
| 3027 |
|
| 3028 |
/***/ }), |
| 3029 |
|
| 3030 |
/***/ "./node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js": |
| 3031 |
/*!********************************************************************************!*\ |
| 3032 |
!*** ./node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js ***! |
| 3033 |
\********************************************************************************/ |
| 3034 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3035 |
|
| 3036 |
__webpack_require__.r(__webpack_exports__); |
| 3037 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3038 |
/* harmony export */ IsRestoringProvider: function() { return /* binding */ IsRestoringProvider; }, |
| 3039 |
/* harmony export */ useIsRestoring: function() { return /* binding */ useIsRestoring; } |
| 3040 |
/* harmony export */ }); |
| 3041 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3042 |
"use client"; |
| 3043 |
|
| 3044 |
// src/IsRestoringProvider.ts |
| 3045 |
|
| 3046 |
var IsRestoringContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(false); |
| 3047 |
var useIsRestoring = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(IsRestoringContext); |
| 3048 |
var IsRestoringProvider = IsRestoringContext.Provider; |
| 3049 |
|
| 3050 |
//# sourceMappingURL=IsRestoringProvider.js.map |
| 3051 |
|
| 3052 |
/***/ }), |
| 3053 |
|
| 3054 |
/***/ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js": |
| 3055 |
/*!********************************************************************************!*\ |
| 3056 |
!*** ./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js ***! |
| 3057 |
\********************************************************************************/ |
| 3058 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3059 |
|
| 3060 |
__webpack_require__.r(__webpack_exports__); |
| 3061 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3062 |
/* harmony export */ QueryClientContext: function() { return /* binding */ QueryClientContext; }, |
| 3063 |
/* harmony export */ QueryClientProvider: function() { return /* binding */ QueryClientProvider; }, |
| 3064 |
/* harmony export */ useQueryClient: function() { return /* binding */ useQueryClient; } |
| 3065 |
/* harmony export */ }); |
| 3066 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3067 |
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); |
| 3068 |
"use client"; |
| 3069 |
|
| 3070 |
// src/QueryClientProvider.tsx |
| 3071 |
|
| 3072 |
|
| 3073 |
var QueryClientContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext( |
| 3074 |
void 0 |
| 3075 |
); |
| 3076 |
var useQueryClient = (queryClient) => { |
| 3077 |
const client = react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryClientContext); |
| 3078 |
if (queryClient) { |
| 3079 |
return queryClient; |
| 3080 |
} |
| 3081 |
if (!client) { |
| 3082 |
throw new Error("No QueryClient set, use QueryClientProvider to set one"); |
| 3083 |
} |
| 3084 |
return client; |
| 3085 |
}; |
| 3086 |
var QueryClientProvider = ({ |
| 3087 |
client, |
| 3088 |
children |
| 3089 |
}) => { |
| 3090 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3091 |
client.mount(); |
| 3092 |
return () => { |
| 3093 |
client.unmount(); |
| 3094 |
}; |
| 3095 |
}, [client]); |
| 3096 |
return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(QueryClientContext.Provider, { value: client, children }); |
| 3097 |
}; |
| 3098 |
|
| 3099 |
//# sourceMappingURL=QueryClientProvider.js.map |
| 3100 |
|
| 3101 |
/***/ }), |
| 3102 |
|
| 3103 |
/***/ "./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js": |
| 3104 |
/*!************************************************************************************!*\ |
| 3105 |
!*** ./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js ***! |
| 3106 |
\************************************************************************************/ |
| 3107 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3108 |
|
| 3109 |
__webpack_require__.r(__webpack_exports__); |
| 3110 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3111 |
/* harmony export */ QueryErrorResetBoundary: function() { return /* binding */ QueryErrorResetBoundary; }, |
| 3112 |
/* harmony export */ useQueryErrorResetBoundary: function() { return /* binding */ useQueryErrorResetBoundary; } |
| 3113 |
/* harmony export */ }); |
| 3114 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3115 |
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "./node_modules/react/jsx-runtime.js"); |
| 3116 |
"use client"; |
| 3117 |
|
| 3118 |
// src/QueryErrorResetBoundary.tsx |
| 3119 |
|
| 3120 |
|
| 3121 |
function createValue() { |
| 3122 |
let isReset = false; |
| 3123 |
return { |
| 3124 |
clearReset: () => { |
| 3125 |
isReset = false; |
| 3126 |
}, |
| 3127 |
reset: () => { |
| 3128 |
isReset = true; |
| 3129 |
}, |
| 3130 |
isReset: () => { |
| 3131 |
return isReset; |
| 3132 |
} |
| 3133 |
}; |
| 3134 |
} |
| 3135 |
var QueryErrorResetBoundaryContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext(createValue()); |
| 3136 |
var useQueryErrorResetBoundary = () => react__WEBPACK_IMPORTED_MODULE_0__.useContext(QueryErrorResetBoundaryContext); |
| 3137 |
var QueryErrorResetBoundary = ({ |
| 3138 |
children |
| 3139 |
}) => { |
| 3140 |
const [value] = react__WEBPACK_IMPORTED_MODULE_0__.useState(() => createValue()); |
| 3141 |
return /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(QueryErrorResetBoundaryContext.Provider, { value, children: typeof children === "function" ? children(value) : children }); |
| 3142 |
}; |
| 3143 |
|
| 3144 |
//# sourceMappingURL=QueryErrorResetBoundary.js.map |
| 3145 |
|
| 3146 |
/***/ }), |
| 3147 |
|
| 3148 |
/***/ "./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js": |
| 3149 |
/*!*******************************************************************************!*\ |
| 3150 |
!*** ./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js ***! |
| 3151 |
\*******************************************************************************/ |
| 3152 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3153 |
|
| 3154 |
__webpack_require__.r(__webpack_exports__); |
| 3155 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3156 |
/* harmony export */ ensurePreventErrorBoundaryRetry: function() { return /* binding */ ensurePreventErrorBoundaryRetry; }, |
| 3157 |
/* harmony export */ getHasError: function() { return /* binding */ getHasError; }, |
| 3158 |
/* harmony export */ useClearResetErrorBoundary: function() { return /* binding */ useClearResetErrorBoundary; } |
| 3159 |
/* harmony export */ }); |
| 3160 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3161 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 3162 |
"use client"; |
| 3163 |
|
| 3164 |
// src/errorBoundaryUtils.ts |
| 3165 |
|
| 3166 |
|
| 3167 |
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => { |
| 3168 |
if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) { |
| 3169 |
if (!errorResetBoundary.isReset()) { |
| 3170 |
options.retryOnMount = false; |
| 3171 |
} |
| 3172 |
} |
| 3173 |
}; |
| 3174 |
var useClearResetErrorBoundary = (errorResetBoundary) => { |
| 3175 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3176 |
errorResetBoundary.clearReset(); |
| 3177 |
}, [errorResetBoundary]); |
| 3178 |
}; |
| 3179 |
var getHasError = ({ |
| 3180 |
result, |
| 3181 |
errorResetBoundary, |
| 3182 |
throwOnError, |
| 3183 |
query, |
| 3184 |
suspense |
| 3185 |
}) => { |
| 3186 |
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.shouldThrowError)(throwOnError, [result.error, query])); |
| 3187 |
}; |
| 3188 |
|
| 3189 |
//# sourceMappingURL=errorBoundaryUtils.js.map |
| 3190 |
|
| 3191 |
/***/ }), |
| 3192 |
|
| 3193 |
/***/ "./node_modules/@tanstack/react-query/build/modern/suspense.js": |
| 3194 |
/*!*********************************************************************!*\ |
| 3195 |
!*** ./node_modules/@tanstack/react-query/build/modern/suspense.js ***! |
| 3196 |
\*********************************************************************/ |
| 3197 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3198 |
|
| 3199 |
__webpack_require__.r(__webpack_exports__); |
| 3200 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3201 |
/* harmony export */ defaultThrowOnError: function() { return /* binding */ defaultThrowOnError; }, |
| 3202 |
/* harmony export */ ensureSuspenseTimers: function() { return /* binding */ ensureSuspenseTimers; }, |
| 3203 |
/* harmony export */ fetchOptimistic: function() { return /* binding */ fetchOptimistic; }, |
| 3204 |
/* harmony export */ shouldSuspend: function() { return /* binding */ shouldSuspend; }, |
| 3205 |
/* harmony export */ willFetch: function() { return /* binding */ willFetch; } |
| 3206 |
/* harmony export */ }); |
| 3207 |
// src/suspense.ts |
| 3208 |
var defaultThrowOnError = (_error, query) => query.state.data === void 0; |
| 3209 |
var ensureSuspenseTimers = (defaultedOptions) => { |
| 3210 |
if (defaultedOptions.suspense) { |
| 3211 |
const MIN_SUSPENSE_TIME_MS = 1e3; |
| 3212 |
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS); |
| 3213 |
const originalStaleTime = defaultedOptions.staleTime; |
| 3214 |
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime); |
| 3215 |
if (typeof defaultedOptions.gcTime === "number") { |
| 3216 |
defaultedOptions.gcTime = Math.max( |
| 3217 |
defaultedOptions.gcTime, |
| 3218 |
MIN_SUSPENSE_TIME_MS |
| 3219 |
); |
| 3220 |
} |
| 3221 |
} |
| 3222 |
}; |
| 3223 |
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring; |
| 3224 |
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending; |
| 3225 |
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => { |
| 3226 |
errorResetBoundary.clearReset(); |
| 3227 |
}); |
| 3228 |
|
| 3229 |
//# sourceMappingURL=suspense.js.map |
| 3230 |
|
| 3231 |
/***/ }), |
| 3232 |
|
| 3233 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js": |
| 3234 |
/*!*************************************************************************!*\ |
| 3235 |
!*** ./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js ***! |
| 3236 |
\*************************************************************************/ |
| 3237 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3238 |
|
| 3239 |
__webpack_require__.r(__webpack_exports__); |
| 3240 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3241 |
/* harmony export */ useBaseQuery: function() { return /* binding */ useBaseQuery; } |
| 3242 |
/* harmony export */ }); |
| 3243 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3244 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 3245 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 3246 |
/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 3247 |
/* harmony import */ var _QueryErrorResetBoundary_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QueryErrorResetBoundary.js */ "./node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js"); |
| 3248 |
/* harmony import */ var _errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./errorBoundaryUtils.js */ "./node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js"); |
| 3249 |
/* harmony import */ var _IsRestoringProvider_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./IsRestoringProvider.js */ "./node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js"); |
| 3250 |
/* harmony import */ var _suspense_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./suspense.js */ "./node_modules/@tanstack/react-query/build/modern/suspense.js"); |
| 3251 |
"use client"; |
| 3252 |
|
| 3253 |
// src/useBaseQuery.ts |
| 3254 |
|
| 3255 |
|
| 3256 |
|
| 3257 |
|
| 3258 |
|
| 3259 |
|
| 3260 |
|
| 3261 |
function useBaseQuery(options, Observer, queryClient) { |
| 3262 |
if (true) { |
| 3263 |
if (typeof options !== "object" || Array.isArray(options)) { |
| 3264 |
throw new Error( |
| 3265 |
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object' |
| 3266 |
); |
| 3267 |
} |
| 3268 |
} |
| 3269 |
const isRestoring = (0,_IsRestoringProvider_js__WEBPACK_IMPORTED_MODULE_6__.useIsRestoring)(); |
| 3270 |
const errorResetBoundary = (0,_QueryErrorResetBoundary_js__WEBPACK_IMPORTED_MODULE_4__.useQueryErrorResetBoundary)(); |
| 3271 |
const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__.useQueryClient)(queryClient); |
| 3272 |
const defaultedOptions = client.defaultQueryOptions(options); |
| 3273 |
client.getDefaultOptions().queries?._experimental_beforeQuery?.( |
| 3274 |
defaultedOptions |
| 3275 |
); |
| 3276 |
if (true) { |
| 3277 |
if (!defaultedOptions.queryFn) { |
| 3278 |
console.error( |
| 3279 |
`[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function` |
| 3280 |
); |
| 3281 |
} |
| 3282 |
} |
| 3283 |
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic"; |
| 3284 |
(0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.ensureSuspenseTimers)(defaultedOptions); |
| 3285 |
(0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.ensurePreventErrorBoundaryRetry)(defaultedOptions, errorResetBoundary); |
| 3286 |
(0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.useClearResetErrorBoundary)(errorResetBoundary); |
| 3287 |
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash); |
| 3288 |
const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState( |
| 3289 |
() => new Observer( |
| 3290 |
client, |
| 3291 |
defaultedOptions |
| 3292 |
) |
| 3293 |
); |
| 3294 |
const result = observer.getOptimisticResult(defaultedOptions); |
| 3295 |
const shouldSubscribe = !isRestoring && options.subscribed !== false; |
| 3296 |
react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( |
| 3297 |
react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 3298 |
(onStoreChange) => { |
| 3299 |
const unsubscribe = shouldSubscribe ? observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.notifyManager.batchCalls(onStoreChange)) : _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.noop; |
| 3300 |
observer.updateResult(); |
| 3301 |
return unsubscribe; |
| 3302 |
}, |
| 3303 |
[observer, shouldSubscribe] |
| 3304 |
), |
| 3305 |
() => observer.getCurrentResult(), |
| 3306 |
() => observer.getCurrentResult() |
| 3307 |
); |
| 3308 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3309 |
observer.setOptions(defaultedOptions); |
| 3310 |
}, [defaultedOptions, observer]); |
| 3311 |
if ((0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.shouldSuspend)(defaultedOptions, result)) { |
| 3312 |
throw (0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.fetchOptimistic)(defaultedOptions, observer, errorResetBoundary); |
| 3313 |
} |
| 3314 |
if ((0,_errorBoundaryUtils_js__WEBPACK_IMPORTED_MODULE_5__.getHasError)({ |
| 3315 |
result, |
| 3316 |
errorResetBoundary, |
| 3317 |
throwOnError: defaultedOptions.throwOnError, |
| 3318 |
query: client.getQueryCache().get(defaultedOptions.queryHash), |
| 3319 |
suspense: defaultedOptions.suspense |
| 3320 |
})) { |
| 3321 |
throw result.error; |
| 3322 |
} |
| 3323 |
; |
| 3324 |
client.getDefaultOptions().queries?._experimental_afterQuery?.( |
| 3325 |
defaultedOptions, |
| 3326 |
result |
| 3327 |
); |
| 3328 |
if (defaultedOptions.experimental_prefetchInRender && !_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.isServer && (0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.willFetch)(result, isRestoring)) { |
| 3329 |
const promise = isNewCacheEntry ? ( |
| 3330 |
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted |
| 3331 |
(0,_suspense_js__WEBPACK_IMPORTED_MODULE_7__.fetchOptimistic)(defaultedOptions, observer, errorResetBoundary) |
| 3332 |
) : ( |
| 3333 |
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in |
| 3334 |
client.getQueryCache().get(defaultedOptions.queryHash)?.promise |
| 3335 |
); |
| 3336 |
promise?.catch(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.noop).finally(() => { |
| 3337 |
observer.updateResult(); |
| 3338 |
}); |
| 3339 |
} |
| 3340 |
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result; |
| 3341 |
} |
| 3342 |
|
| 3343 |
//# sourceMappingURL=useBaseQuery.js.map |
| 3344 |
|
| 3345 |
/***/ }), |
| 3346 |
|
| 3347 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js": |
| 3348 |
/*!*****************************************************************************!*\ |
| 3349 |
!*** ./node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js ***! |
| 3350 |
\*****************************************************************************/ |
| 3351 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3352 |
|
| 3353 |
__webpack_require__.r(__webpack_exports__); |
| 3354 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3355 |
/* harmony export */ useInfiniteQuery: function() { return /* binding */ useInfiniteQuery; } |
| 3356 |
/* harmony export */ }); |
| 3357 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js"); |
| 3358 |
/* harmony import */ var _useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./useBaseQuery.js */ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"); |
| 3359 |
"use client"; |
| 3360 |
|
| 3361 |
// src/useInfiniteQuery.ts |
| 3362 |
|
| 3363 |
|
| 3364 |
function useInfiniteQuery(options, queryClient) { |
| 3365 |
return (0,_useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__.useBaseQuery)( |
| 3366 |
options, |
| 3367 |
_tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__.InfiniteQueryObserver, |
| 3368 |
queryClient |
| 3369 |
); |
| 3370 |
} |
| 3371 |
|
| 3372 |
//# sourceMappingURL=useInfiniteQuery.js.map |
| 3373 |
|
| 3374 |
/***/ }), |
| 3375 |
|
| 3376 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useMutation.js": |
| 3377 |
/*!************************************************************************!*\ |
| 3378 |
!*** ./node_modules/@tanstack/react-query/build/modern/useMutation.js ***! |
| 3379 |
\************************************************************************/ |
| 3380 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3381 |
|
| 3382 |
__webpack_require__.r(__webpack_exports__); |
| 3383 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3384 |
/* harmony export */ useMutation: function() { return /* binding */ useMutation; } |
| 3385 |
/* harmony export */ }); |
| 3386 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3387 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/mutationObserver.js"); |
| 3388 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 3389 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 3390 |
/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 3391 |
"use client"; |
| 3392 |
|
| 3393 |
// src/useMutation.ts |
| 3394 |
|
| 3395 |
|
| 3396 |
|
| 3397 |
function useMutation(options, queryClient) { |
| 3398 |
const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_4__.useQueryClient)(queryClient); |
| 3399 |
const [observer] = react__WEBPACK_IMPORTED_MODULE_0__.useState( |
| 3400 |
() => new _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.MutationObserver( |
| 3401 |
client, |
| 3402 |
options |
| 3403 |
) |
| 3404 |
); |
| 3405 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3406 |
observer.setOptions(options); |
| 3407 |
}, [observer, options]); |
| 3408 |
const result = react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( |
| 3409 |
react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 3410 |
(onStoreChange) => observer.subscribe(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.notifyManager.batchCalls(onStoreChange)), |
| 3411 |
[observer] |
| 3412 |
), |
| 3413 |
() => observer.getCurrentResult(), |
| 3414 |
() => observer.getCurrentResult() |
| 3415 |
); |
| 3416 |
const mutate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 3417 |
(variables, mutateOptions) => { |
| 3418 |
observer.mutate(variables, mutateOptions).catch(_tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__.noop); |
| 3419 |
}, |
| 3420 |
[observer] |
| 3421 |
); |
| 3422 |
if (result.error && (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_3__.shouldThrowError)(observer.options.throwOnError, [result.error])) { |
| 3423 |
throw result.error; |
| 3424 |
} |
| 3425 |
return { ...result, mutate, mutateAsync: result.mutate }; |
| 3426 |
} |
| 3427 |
|
| 3428 |
//# sourceMappingURL=useMutation.js.map |
| 3429 |
|
| 3430 |
/***/ }), |
| 3431 |
|
| 3432 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useMutationState.js": |
| 3433 |
/*!*****************************************************************************!*\ |
| 3434 |
!*** ./node_modules/@tanstack/react-query/build/modern/useMutationState.js ***! |
| 3435 |
\*****************************************************************************/ |
| 3436 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3437 |
|
| 3438 |
__webpack_require__.r(__webpack_exports__); |
| 3439 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3440 |
/* harmony export */ useIsMutating: function() { return /* binding */ useIsMutating; }, |
| 3441 |
/* harmony export */ useMutationState: function() { return /* binding */ useMutationState; } |
| 3442 |
/* harmony export */ }); |
| 3443 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 3444 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/notifyManager.js"); |
| 3445 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/utils.js"); |
| 3446 |
/* harmony import */ var _QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QueryClientProvider.js */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 3447 |
"use client"; |
| 3448 |
|
| 3449 |
// src/useMutationState.ts |
| 3450 |
|
| 3451 |
|
| 3452 |
|
| 3453 |
function useIsMutating(filters, queryClient) { |
| 3454 |
const client = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__.useQueryClient)(queryClient); |
| 3455 |
return useMutationState( |
| 3456 |
{ filters: { ...filters, status: "pending" } }, |
| 3457 |
client |
| 3458 |
).length; |
| 3459 |
} |
| 3460 |
function getResult(mutationCache, options) { |
| 3461 |
return mutationCache.findAll(options.filters).map( |
| 3462 |
(mutation) => options.select ? options.select(mutation) : mutation.state |
| 3463 |
); |
| 3464 |
} |
| 3465 |
function useMutationState(options = {}, queryClient) { |
| 3466 |
const mutationCache = (0,_QueryClientProvider_js__WEBPACK_IMPORTED_MODULE_3__.useQueryClient)(queryClient).getMutationCache(); |
| 3467 |
const optionsRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(options); |
| 3468 |
const result = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null); |
| 3469 |
if (result.current === null) { |
| 3470 |
result.current = getResult(mutationCache, options); |
| 3471 |
} |
| 3472 |
react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => { |
| 3473 |
optionsRef.current = options; |
| 3474 |
}); |
| 3475 |
return react__WEBPACK_IMPORTED_MODULE_0__.useSyncExternalStore( |
| 3476 |
react__WEBPACK_IMPORTED_MODULE_0__.useCallback( |
| 3477 |
(onStoreChange) => mutationCache.subscribe(() => { |
| 3478 |
const nextResult = (0,_tanstack_query_core__WEBPACK_IMPORTED_MODULE_2__.replaceEqualDeep)( |
| 3479 |
result.current, |
| 3480 |
getResult(mutationCache, optionsRef.current) |
| 3481 |
); |
| 3482 |
if (result.current !== nextResult) { |
| 3483 |
result.current = nextResult; |
| 3484 |
_tanstack_query_core__WEBPACK_IMPORTED_MODULE_1__.notifyManager.schedule(onStoreChange); |
| 3485 |
} |
| 3486 |
}), |
| 3487 |
[mutationCache] |
| 3488 |
), |
| 3489 |
() => result.current, |
| 3490 |
() => result.current |
| 3491 |
); |
| 3492 |
} |
| 3493 |
|
| 3494 |
//# sourceMappingURL=useMutationState.js.map |
| 3495 |
|
| 3496 |
/***/ }), |
| 3497 |
|
| 3498 |
/***/ "./node_modules/@tanstack/react-query/build/modern/useQuery.js": |
| 3499 |
/*!*********************************************************************!*\ |
| 3500 |
!*** ./node_modules/@tanstack/react-query/build/modern/useQuery.js ***! |
| 3501 |
\*********************************************************************/ |
| 3502 |
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { |
| 3503 |
|
| 3504 |
__webpack_require__.r(__webpack_exports__); |
| 3505 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3506 |
/* harmony export */ useQuery: function() { return /* binding */ useQuery; } |
| 3507 |
/* harmony export */ }); |
| 3508 |
/* harmony import */ var _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/query-core */ "./node_modules/@tanstack/query-core/build/modern/queryObserver.js"); |
| 3509 |
/* harmony import */ var _useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./useBaseQuery.js */ "./node_modules/@tanstack/react-query/build/modern/useBaseQuery.js"); |
| 3510 |
"use client"; |
| 3511 |
|
| 3512 |
// src/useQuery.ts |
| 3513 |
|
| 3514 |
|
| 3515 |
function useQuery(options, queryClient) { |
| 3516 |
return (0,_useBaseQuery_js__WEBPACK_IMPORTED_MODULE_1__.useBaseQuery)(options, _tanstack_query_core__WEBPACK_IMPORTED_MODULE_0__.QueryObserver, queryClient); |
| 3517 |
} |
| 3518 |
|
| 3519 |
//# sourceMappingURL=useQuery.js.map |
| 3520 |
|
| 3521 |
/***/ }), |
| 3522 |
|
| 3523 |
/***/ "./node_modules/react/cjs/react-jsx-runtime.development.js": |
| 3524 |
/*!*****************************************************************!*\ |
| 3525 |
!*** ./node_modules/react/cjs/react-jsx-runtime.development.js ***! |
| 3526 |
\*****************************************************************/ |
| 3527 |
/***/ (function(__unused_webpack_module, exports, __webpack_require__) { |
| 3528 |
|
| 3529 |
/** |
| 3530 |
* @license React |
| 3531 |
* react-jsx-runtime.development.js |
| 3532 |
* |
| 3533 |
* Copyright (c) Facebook, Inc. and its affiliates. |
| 3534 |
* |
| 3535 |
* This source code is licensed under the MIT license found in the |
| 3536 |
* LICENSE file in the root directory of this source tree. |
| 3537 |
*/ |
| 3538 |
|
| 3539 |
|
| 3540 |
|
| 3541 |
if (true) { |
| 3542 |
(function() { |
| 3543 |
'use strict'; |
| 3544 |
|
| 3545 |
var React = __webpack_require__(/*! react */ "react"); |
| 3546 |
|
| 3547 |
// ATTENTION |
| 3548 |
// When adding new symbols to this file, |
| 3549 |
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' |
| 3550 |
// The Symbol used to tag the ReactElement-like types. |
| 3551 |
var REACT_ELEMENT_TYPE = Symbol.for('react.element'); |
| 3552 |
var REACT_PORTAL_TYPE = Symbol.for('react.portal'); |
| 3553 |
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment'); |
| 3554 |
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode'); |
| 3555 |
var REACT_PROFILER_TYPE = Symbol.for('react.profiler'); |
| 3556 |
var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); |
| 3557 |
var REACT_CONTEXT_TYPE = Symbol.for('react.context'); |
| 3558 |
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref'); |
| 3559 |
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense'); |
| 3560 |
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list'); |
| 3561 |
var REACT_MEMO_TYPE = Symbol.for('react.memo'); |
| 3562 |
var REACT_LAZY_TYPE = Symbol.for('react.lazy'); |
| 3563 |
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen'); |
| 3564 |
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator; |
| 3565 |
var FAUX_ITERATOR_SYMBOL = '@@iterator'; |
| 3566 |
function getIteratorFn(maybeIterable) { |
| 3567 |
if (maybeIterable === null || typeof maybeIterable !== 'object') { |
| 3568 |
return null; |
| 3569 |
} |
| 3570 |
|
| 3571 |
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; |
| 3572 |
|
| 3573 |
if (typeof maybeIterator === 'function') { |
| 3574 |
return maybeIterator; |
| 3575 |
} |
| 3576 |
|
| 3577 |
return null; |
| 3578 |
} |
| 3579 |
|
| 3580 |
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; |
| 3581 |
|
| 3582 |
function error(format) { |
| 3583 |
{ |
| 3584 |
{ |
| 3585 |
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { |
| 3586 |
args[_key2 - 1] = arguments[_key2]; |
| 3587 |
} |
| 3588 |
|
| 3589 |
printWarning('error', format, args); |
| 3590 |
} |
| 3591 |
} |
| 3592 |
} |
| 3593 |
|
| 3594 |
function printWarning(level, format, args) { |
| 3595 |
// When changing this logic, you might want to also |
| 3596 |
// update consoleWithStackDev.www.js as well. |
| 3597 |
{ |
| 3598 |
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; |
| 3599 |
var stack = ReactDebugCurrentFrame.getStackAddendum(); |
| 3600 |
|
| 3601 |
if (stack !== '') { |
| 3602 |
format += '%s'; |
| 3603 |
args = args.concat([stack]); |
| 3604 |
} // eslint-disable-next-line react-internal/safe-string-coercion |
| 3605 |
|
| 3606 |
|
| 3607 |
var argsWithFormat = args.map(function (item) { |
| 3608 |
return String(item); |
| 3609 |
}); // Careful: RN currently depends on this prefix |
| 3610 |
|
| 3611 |
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it |
| 3612 |
// breaks IE9: https://github.com/facebook/react/issues/13610 |
| 3613 |
// eslint-disable-next-line react-internal/no-production-logging |
| 3614 |
|
| 3615 |
Function.prototype.apply.call(console[level], console, argsWithFormat); |
| 3616 |
} |
| 3617 |
} |
| 3618 |
|
| 3619 |
// ----------------------------------------------------------------------------- |
| 3620 |
|
| 3621 |
var enableScopeAPI = false; // Experimental Create Event Handle API. |
| 3622 |
var enableCacheElement = false; |
| 3623 |
var enableTransitionTracing = false; // No known bugs, but needs performance testing |
| 3624 |
|
| 3625 |
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber |
| 3626 |
// stuff. Intended to enable React core members to more easily debug scheduling |
| 3627 |
// issues in DEV builds. |
| 3628 |
|
| 3629 |
var enableDebugTracing = false; // Track which Fiber(s) schedule render work. |
| 3630 |
|
| 3631 |
var REACT_MODULE_REFERENCE; |
| 3632 |
|
| 3633 |
{ |
| 3634 |
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference'); |
| 3635 |
} |
| 3636 |
|
| 3637 |
function isValidElementType(type) { |
| 3638 |
if (typeof type === 'string' || typeof type === 'function') { |
| 3639 |
return true; |
| 3640 |
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill). |
| 3641 |
|
| 3642 |
|
| 3643 |
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) { |
| 3644 |
return true; |
| 3645 |
} |
| 3646 |
|
| 3647 |
if (typeof type === 'object' && type !== null) { |
| 3648 |
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object |
| 3649 |
// types supported by any Flight configuration anywhere since |
| 3650 |
// we don't know which Flight build this will end up being used |
| 3651 |
// with. |
| 3652 |
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) { |
| 3653 |
return true; |
| 3654 |
} |
| 3655 |
} |
| 3656 |
|
| 3657 |
return false; |
| 3658 |
} |
| 3659 |
|
| 3660 |
function getWrappedName(outerType, innerType, wrapperName) { |
| 3661 |
var displayName = outerType.displayName; |
| 3662 |
|
| 3663 |
if (displayName) { |
| 3664 |
return displayName; |
| 3665 |
} |
| 3666 |
|
| 3667 |
var functionName = innerType.displayName || innerType.name || ''; |
| 3668 |
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName; |
| 3669 |
} // Keep in sync with react-reconciler/getComponentNameFromFiber |
| 3670 |
|
| 3671 |
|
| 3672 |
function getContextName(type) { |
| 3673 |
return type.displayName || 'Context'; |
| 3674 |
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. |
| 3675 |
|
| 3676 |
|
| 3677 |
function getComponentNameFromType(type) { |
| 3678 |
if (type == null) { |
| 3679 |
// Host root, text node or just invalid type. |
| 3680 |
return null; |
| 3681 |
} |
| 3682 |
|
| 3683 |
{ |
| 3684 |
if (typeof type.tag === 'number') { |
| 3685 |
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.'); |
| 3686 |
} |
| 3687 |
} |
| 3688 |
|
| 3689 |
if (typeof type === 'function') { |
| 3690 |
return type.displayName || type.name || null; |
| 3691 |
} |
| 3692 |
|
| 3693 |
if (typeof type === 'string') { |
| 3694 |
return type; |
| 3695 |
} |
| 3696 |
|
| 3697 |
switch (type) { |
| 3698 |
case REACT_FRAGMENT_TYPE: |
| 3699 |
return 'Fragment'; |
| 3700 |
|
| 3701 |
case REACT_PORTAL_TYPE: |
| 3702 |
return 'Portal'; |
| 3703 |
|
| 3704 |
case REACT_PROFILER_TYPE: |
| 3705 |
return 'Profiler'; |
| 3706 |
|
| 3707 |
case REACT_STRICT_MODE_TYPE: |
| 3708 |
return 'StrictMode'; |
| 3709 |
|
| 3710 |
case REACT_SUSPENSE_TYPE: |
| 3711 |
return 'Suspense'; |
| 3712 |
|
| 3713 |
case REACT_SUSPENSE_LIST_TYPE: |
| 3714 |
return 'SuspenseList'; |
| 3715 |
|
| 3716 |
} |
| 3717 |
|
| 3718 |
if (typeof type === 'object') { |
| 3719 |
switch (type.$$typeof) { |
| 3720 |
case REACT_CONTEXT_TYPE: |
| 3721 |
var context = type; |
| 3722 |
return getContextName(context) + '.Consumer'; |
| 3723 |
|
| 3724 |
case REACT_PROVIDER_TYPE: |
| 3725 |
var provider = type; |
| 3726 |
return getContextName(provider._context) + '.Provider'; |
| 3727 |
|
| 3728 |
case REACT_FORWARD_REF_TYPE: |
| 3729 |
return getWrappedName(type, type.render, 'ForwardRef'); |
| 3730 |
|
| 3731 |
case REACT_MEMO_TYPE: |
| 3732 |
var outerName = type.displayName || null; |
| 3733 |
|
| 3734 |
if (outerName !== null) { |
| 3735 |
return outerName; |
| 3736 |
} |
| 3737 |
|
| 3738 |
return getComponentNameFromType(type.type) || 'Memo'; |
| 3739 |
|
| 3740 |
case REACT_LAZY_TYPE: |
| 3741 |
{ |
| 3742 |
var lazyComponent = type; |
| 3743 |
var payload = lazyComponent._payload; |
| 3744 |
var init = lazyComponent._init; |
| 3745 |
|
| 3746 |
try { |
| 3747 |
return getComponentNameFromType(init(payload)); |
| 3748 |
} catch (x) { |
| 3749 |
return null; |
| 3750 |
} |
| 3751 |
} |
| 3752 |
|
| 3753 |
// eslint-disable-next-line no-fallthrough |
| 3754 |
} |
| 3755 |
} |
| 3756 |
|
| 3757 |
return null; |
| 3758 |
} |
| 3759 |
|
| 3760 |
var assign = Object.assign; |
| 3761 |
|
| 3762 |
// Helpers to patch console.logs to avoid logging during side-effect free |
| 3763 |
// replaying on render function. This currently only patches the object |
| 3764 |
// lazily which won't cover if the log function was extracted eagerly. |
| 3765 |
// We could also eagerly patch the method. |
| 3766 |
var disabledDepth = 0; |
| 3767 |
var prevLog; |
| 3768 |
var prevInfo; |
| 3769 |
var prevWarn; |
| 3770 |
var prevError; |
| 3771 |
var prevGroup; |
| 3772 |
var prevGroupCollapsed; |
| 3773 |
var prevGroupEnd; |
| 3774 |
|
| 3775 |
function disabledLog() {} |
| 3776 |
|
| 3777 |
disabledLog.__reactDisabledLog = true; |
| 3778 |
function disableLogs() { |
| 3779 |
{ |
| 3780 |
if (disabledDepth === 0) { |
| 3781 |
/* eslint-disable react-internal/no-production-logging */ |
| 3782 |
prevLog = console.log; |
| 3783 |
prevInfo = console.info; |
| 3784 |
prevWarn = console.warn; |
| 3785 |
prevError = console.error; |
| 3786 |
prevGroup = console.group; |
| 3787 |
prevGroupCollapsed = console.groupCollapsed; |
| 3788 |
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 |
| 3789 |
|
| 3790 |
var props = { |
| 3791 |
configurable: true, |
| 3792 |
enumerable: true, |
| 3793 |
value: disabledLog, |
| 3794 |
writable: true |
| 3795 |
}; // $FlowFixMe Flow thinks console is immutable. |
| 3796 |
|
| 3797 |
Object.defineProperties(console, { |
| 3798 |
info: props, |
| 3799 |
log: props, |
| 3800 |
warn: props, |
| 3801 |
error: props, |
| 3802 |
group: props, |
| 3803 |
groupCollapsed: props, |
| 3804 |
groupEnd: props |
| 3805 |
}); |
| 3806 |
/* eslint-enable react-internal/no-production-logging */ |
| 3807 |
} |
| 3808 |
|
| 3809 |
disabledDepth++; |
| 3810 |
} |
| 3811 |
} |
| 3812 |
function reenableLogs() { |
| 3813 |
{ |
| 3814 |
disabledDepth--; |
| 3815 |
|
| 3816 |
if (disabledDepth === 0) { |
| 3817 |
/* eslint-disable react-internal/no-production-logging */ |
| 3818 |
var props = { |
| 3819 |
configurable: true, |
| 3820 |
enumerable: true, |
| 3821 |
writable: true |
| 3822 |
}; // $FlowFixMe Flow thinks console is immutable. |
| 3823 |
|
| 3824 |
Object.defineProperties(console, { |
| 3825 |
log: assign({}, props, { |
| 3826 |
value: prevLog |
| 3827 |
}), |
| 3828 |
info: assign({}, props, { |
| 3829 |
value: prevInfo |
| 3830 |
}), |
| 3831 |
warn: assign({}, props, { |
| 3832 |
value: prevWarn |
| 3833 |
}), |
| 3834 |
error: assign({}, props, { |
| 3835 |
value: prevError |
| 3836 |
}), |
| 3837 |
group: assign({}, props, { |
| 3838 |
value: prevGroup |
| 3839 |
}), |
| 3840 |
groupCollapsed: assign({}, props, { |
| 3841 |
value: prevGroupCollapsed |
| 3842 |
}), |
| 3843 |
groupEnd: assign({}, props, { |
| 3844 |
value: prevGroupEnd |
| 3845 |
}) |
| 3846 |
}); |
| 3847 |
/* eslint-enable react-internal/no-production-logging */ |
| 3848 |
} |
| 3849 |
|
| 3850 |
if (disabledDepth < 0) { |
| 3851 |
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.'); |
| 3852 |
} |
| 3853 |
} |
| 3854 |
} |
| 3855 |
|
| 3856 |
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; |
| 3857 |
var prefix; |
| 3858 |
function describeBuiltInComponentFrame(name, source, ownerFn) { |
| 3859 |
{ |
| 3860 |
if (prefix === undefined) { |
| 3861 |
// Extract the VM specific prefix used by each line. |
| 3862 |
try { |
| 3863 |
throw Error(); |
| 3864 |
} catch (x) { |
| 3865 |
var match = x.stack.trim().match(/\n( *(at )?)/); |
| 3866 |
prefix = match && match[1] || ''; |
| 3867 |
} |
| 3868 |
} // We use the prefix to ensure our stacks line up with native stack frames. |
| 3869 |
|
| 3870 |
|
| 3871 |
return '\n' + prefix + name; |
| 3872 |
} |
| 3873 |
} |
| 3874 |
var reentry = false; |
| 3875 |
var componentFrameCache; |
| 3876 |
|
| 3877 |
{ |
| 3878 |
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; |
| 3879 |
componentFrameCache = new PossiblyWeakMap(); |
| 3880 |
} |
| 3881 |
|
| 3882 |
function describeNativeComponentFrame(fn, construct) { |
| 3883 |
// If something asked for a stack inside a fake render, it should get ignored. |
| 3884 |
if ( !fn || reentry) { |
| 3885 |
return ''; |
| 3886 |
} |
| 3887 |
|
| 3888 |
{ |
| 3889 |
var frame = componentFrameCache.get(fn); |
| 3890 |
|
| 3891 |
if (frame !== undefined) { |
| 3892 |
return frame; |
| 3893 |
} |
| 3894 |
} |
| 3895 |
|
| 3896 |
var control; |
| 3897 |
reentry = true; |
| 3898 |
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined. |
| 3899 |
|
| 3900 |
Error.prepareStackTrace = undefined; |
| 3901 |
var previousDispatcher; |
| 3902 |
|
| 3903 |
{ |
| 3904 |
previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function |
| 3905 |
// for warnings. |
| 3906 |
|
| 3907 |
ReactCurrentDispatcher.current = null; |
| 3908 |
disableLogs(); |
| 3909 |
} |
| 3910 |
|
| 3911 |
try { |
| 3912 |
// This should throw. |
| 3913 |
if (construct) { |
| 3914 |
// Something should be setting the props in the constructor. |
| 3915 |
var Fake = function () { |
| 3916 |
throw Error(); |
| 3917 |
}; // $FlowFixMe |
| 3918 |
|
| 3919 |
|
| 3920 |
Object.defineProperty(Fake.prototype, 'props', { |
| 3921 |
set: function () { |
| 3922 |
// We use a throwing setter instead of frozen or non-writable props |
| 3923 |
// because that won't throw in a non-strict mode function. |
| 3924 |
throw Error(); |
| 3925 |
} |
| 3926 |
}); |
| 3927 |
|
| 3928 |
if (typeof Reflect === 'object' && Reflect.construct) { |
| 3929 |
// We construct a different control for this case to include any extra |
| 3930 |
// frames added by the construct call. |
| 3931 |
try { |
| 3932 |
Reflect.construct(Fake, []); |
| 3933 |
} catch (x) { |
| 3934 |
control = x; |
| 3935 |
} |
| 3936 |
|
| 3937 |
Reflect.construct(fn, [], Fake); |
| 3938 |
} else { |
| 3939 |
try { |
| 3940 |
Fake.call(); |
| 3941 |
} catch (x) { |
| 3942 |
control = x; |
| 3943 |
} |
| 3944 |
|
| 3945 |
fn.call(Fake.prototype); |
| 3946 |
} |
| 3947 |
} else { |
| 3948 |
try { |
| 3949 |
throw Error(); |
| 3950 |
} catch (x) { |
| 3951 |
control = x; |
| 3952 |
} |
| 3953 |
|
| 3954 |
fn(); |
| 3955 |
} |
| 3956 |
} catch (sample) { |
| 3957 |
// This is inlined manually because closure doesn't do it for us. |
| 3958 |
if (sample && control && typeof sample.stack === 'string') { |
| 3959 |
// This extracts the first frame from the sample that isn't also in the control. |
| 3960 |
// Skipping one frame that we assume is the frame that calls the two. |
| 3961 |
var sampleLines = sample.stack.split('\n'); |
| 3962 |
var controlLines = control.stack.split('\n'); |
| 3963 |
var s = sampleLines.length - 1; |
| 3964 |
var c = controlLines.length - 1; |
| 3965 |
|
| 3966 |
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) { |
| 3967 |
// We expect at least one stack frame to be shared. |
| 3968 |
// Typically this will be the root most one. However, stack frames may be |
| 3969 |
// cut off due to maximum stack limits. In this case, one maybe cut off |
| 3970 |
// earlier than the other. We assume that the sample is longer or the same |
| 3971 |
// and there for cut off earlier. So we should find the root most frame in |
| 3972 |
// the sample somewhere in the control. |
| 3973 |
c--; |
| 3974 |
} |
| 3975 |
|
| 3976 |
for (; s >= 1 && c >= 0; s--, c--) { |
| 3977 |
// Next we find the first one that isn't the same which should be the |
| 3978 |
// frame that called our sample function and the control. |
| 3979 |
if (sampleLines[s] !== controlLines[c]) { |
| 3980 |
// In V8, the first line is describing the message but other VMs don't. |
| 3981 |
// If we're about to return the first line, and the control is also on the same |
| 3982 |
// line, that's a pretty good indicator that our sample threw at same line as |
| 3983 |
// the control. I.e. before we entered the sample frame. So we ignore this result. |
| 3984 |
// This can happen if you passed a class to function component, or non-function. |
| 3985 |
if (s !== 1 || c !== 1) { |
| 3986 |
do { |
| 3987 |
s--; |
| 3988 |
c--; // We may still have similar intermediate frames from the construct call. |
| 3989 |
// The next one that isn't the same should be our match though. |
| 3990 |
|
| 3991 |
if (c < 0 || sampleLines[s] !== controlLines[c]) { |
| 3992 |
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier. |
| 3993 |
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>" |
| 3994 |
// but we have a user-provided "displayName" |
| 3995 |
// splice it in to make the stack more readable. |
| 3996 |
|
| 3997 |
|
| 3998 |
if (fn.displayName && _frame.includes('<anonymous>')) { |
| 3999 |
_frame = _frame.replace('<anonymous>', fn.displayName); |
| 4000 |
} |
| 4001 |
|
| 4002 |
{ |
| 4003 |
if (typeof fn === 'function') { |
| 4004 |
componentFrameCache.set(fn, _frame); |
| 4005 |
} |
| 4006 |
} // Return the line we found. |
| 4007 |
|
| 4008 |
|
| 4009 |
return _frame; |
| 4010 |
} |
| 4011 |
} while (s >= 1 && c >= 0); |
| 4012 |
} |
| 4013 |
|
| 4014 |
break; |
| 4015 |
} |
| 4016 |
} |
| 4017 |
} |
| 4018 |
} finally { |
| 4019 |
reentry = false; |
| 4020 |
|
| 4021 |
{ |
| 4022 |
ReactCurrentDispatcher.current = previousDispatcher; |
| 4023 |
reenableLogs(); |
| 4024 |
} |
| 4025 |
|
| 4026 |
Error.prepareStackTrace = previousPrepareStackTrace; |
| 4027 |
} // Fallback to just using the name if we couldn't make it throw. |
| 4028 |
|
| 4029 |
|
| 4030 |
var name = fn ? fn.displayName || fn.name : ''; |
| 4031 |
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : ''; |
| 4032 |
|
| 4033 |
{ |
| 4034 |
if (typeof fn === 'function') { |
| 4035 |
componentFrameCache.set(fn, syntheticFrame); |
| 4036 |
} |
| 4037 |
} |
| 4038 |
|
| 4039 |
return syntheticFrame; |
| 4040 |
} |
| 4041 |
function describeFunctionComponentFrame(fn, source, ownerFn) { |
| 4042 |
{ |
| 4043 |
return describeNativeComponentFrame(fn, false); |
| 4044 |
} |
| 4045 |
} |
| 4046 |
|
| 4047 |
function shouldConstruct(Component) { |
| 4048 |
var prototype = Component.prototype; |
| 4049 |
return !!(prototype && prototype.isReactComponent); |
| 4050 |
} |
| 4051 |
|
| 4052 |
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { |
| 4053 |
|
| 4054 |
if (type == null) { |
| 4055 |
return ''; |
| 4056 |
} |
| 4057 |
|
| 4058 |
if (typeof type === 'function') { |
| 4059 |
{ |
| 4060 |
return describeNativeComponentFrame(type, shouldConstruct(type)); |
| 4061 |
} |
| 4062 |
} |
| 4063 |
|
| 4064 |
if (typeof type === 'string') { |
| 4065 |
return describeBuiltInComponentFrame(type); |
| 4066 |
} |
| 4067 |
|
| 4068 |
switch (type) { |
| 4069 |
case REACT_SUSPENSE_TYPE: |
| 4070 |
return describeBuiltInComponentFrame('Suspense'); |
| 4071 |
|
| 4072 |
case REACT_SUSPENSE_LIST_TYPE: |
| 4073 |
return describeBuiltInComponentFrame('SuspenseList'); |
| 4074 |
} |
| 4075 |
|
| 4076 |
if (typeof type === 'object') { |
| 4077 |
switch (type.$$typeof) { |
| 4078 |
case REACT_FORWARD_REF_TYPE: |
| 4079 |
return describeFunctionComponentFrame(type.render); |
| 4080 |
|
| 4081 |
case REACT_MEMO_TYPE: |
| 4082 |
// Memo may contain any component type so we recursively resolve it. |
| 4083 |
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); |
| 4084 |
|
| 4085 |
case REACT_LAZY_TYPE: |
| 4086 |
{ |
| 4087 |
var lazyComponent = type; |
| 4088 |
var payload = lazyComponent._payload; |
| 4089 |
var init = lazyComponent._init; |
| 4090 |
|
| 4091 |
try { |
| 4092 |
// Lazy may contain any component type so we recursively resolve it. |
| 4093 |
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn); |
| 4094 |
} catch (x) {} |
| 4095 |
} |
| 4096 |
} |
| 4097 |
} |
| 4098 |
|
| 4099 |
return ''; |
| 4100 |
} |
| 4101 |
|
| 4102 |
var hasOwnProperty = Object.prototype.hasOwnProperty; |
| 4103 |
|
| 4104 |
var loggedTypeFailures = {}; |
| 4105 |
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; |
| 4106 |
|
| 4107 |
function setCurrentlyValidatingElement(element) { |
| 4108 |
{ |
| 4109 |
if (element) { |
| 4110 |
var owner = element._owner; |
| 4111 |
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); |
| 4112 |
ReactDebugCurrentFrame.setExtraStackFrame(stack); |
| 4113 |
} else { |
| 4114 |
ReactDebugCurrentFrame.setExtraStackFrame(null); |
| 4115 |
} |
| 4116 |
} |
| 4117 |
} |
| 4118 |
|
| 4119 |
function checkPropTypes(typeSpecs, values, location, componentName, element) { |
| 4120 |
{ |
| 4121 |
// $FlowFixMe This is okay but Flow doesn't know it. |
| 4122 |
var has = Function.call.bind(hasOwnProperty); |
| 4123 |
|
| 4124 |
for (var typeSpecName in typeSpecs) { |
| 4125 |
if (has(typeSpecs, typeSpecName)) { |
| 4126 |
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to |
| 4127 |
// fail the render phase where it didn't fail before. So we log it. |
| 4128 |
// After these have been cleaned up, we'll let them throw. |
| 4129 |
|
| 4130 |
try { |
| 4131 |
// This is intentionally an invariant that gets caught. It's the same |
| 4132 |
// behavior as without this statement except with a better message. |
| 4133 |
if (typeof typeSpecs[typeSpecName] !== 'function') { |
| 4134 |
// eslint-disable-next-line react-internal/prod-error-codes |
| 4135 |
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'); |
| 4136 |
err.name = 'Invariant Violation'; |
| 4137 |
throw err; |
| 4138 |
} |
| 4139 |
|
| 4140 |
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'); |
| 4141 |
} catch (ex) { |
| 4142 |
error$1 = ex; |
| 4143 |
} |
| 4144 |
|
| 4145 |
if (error$1 && !(error$1 instanceof Error)) { |
| 4146 |
setCurrentlyValidatingElement(element); |
| 4147 |
|
| 4148 |
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1); |
| 4149 |
|
| 4150 |
setCurrentlyValidatingElement(null); |
| 4151 |
} |
| 4152 |
|
| 4153 |
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { |
| 4154 |
// Only monitor this failure once because there tends to be a lot of the |
| 4155 |
// same error. |
| 4156 |
loggedTypeFailures[error$1.message] = true; |
| 4157 |
setCurrentlyValidatingElement(element); |
| 4158 |
|
| 4159 |
error('Failed %s type: %s', location, error$1.message); |
| 4160 |
|
| 4161 |
setCurrentlyValidatingElement(null); |
| 4162 |
} |
| 4163 |
} |
| 4164 |
} |
| 4165 |
} |
| 4166 |
} |
| 4167 |
|
| 4168 |
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare |
| 4169 |
|
| 4170 |
function isArray(a) { |
| 4171 |
return isArrayImpl(a); |
| 4172 |
} |
| 4173 |
|
| 4174 |
/* |
| 4175 |
* The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol |
| 4176 |
* and Temporal.* types. See https://github.com/facebook/react/pull/22064. |
| 4177 |
* |
| 4178 |
* The functions in this module will throw an easier-to-understand, |
| 4179 |
* easier-to-debug exception with a clear errors message message explaining the |
| 4180 |
* problem. (Instead of a confusing exception thrown inside the implementation |
| 4181 |
* of the `value` object). |
| 4182 |
*/ |
| 4183 |
// $FlowFixMe only called in DEV, so void return is not possible. |
| 4184 |
function typeName(value) { |
| 4185 |
{ |
| 4186 |
// toStringTag is needed for namespaced types like Temporal.Instant |
| 4187 |
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag; |
| 4188 |
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; |
| 4189 |
return type; |
| 4190 |
} |
| 4191 |
} // $FlowFixMe only called in DEV, so void return is not possible. |
| 4192 |
|
| 4193 |
|
| 4194 |
function willCoercionThrow(value) { |
| 4195 |
{ |
| 4196 |
try { |
| 4197 |
testStringCoercion(value); |
| 4198 |
return false; |
| 4199 |
} catch (e) { |
| 4200 |
return true; |
| 4201 |
} |
| 4202 |
} |
| 4203 |
} |
| 4204 |
|
| 4205 |
function testStringCoercion(value) { |
| 4206 |
// If you ended up here by following an exception call stack, here's what's |
| 4207 |
// happened: you supplied an object or symbol value to React (as a prop, key, |
| 4208 |
// DOM attribute, CSS property, string ref, etc.) and when React tried to |
| 4209 |
// coerce it to a string using `'' + value`, an exception was thrown. |
| 4210 |
// |
| 4211 |
// The most common types that will cause this exception are `Symbol` instances |
| 4212 |
// and Temporal objects like `Temporal.Instant`. But any object that has a |
| 4213 |
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this |
| 4214 |
// exception. (Library authors do this to prevent users from using built-in |
| 4215 |
// numeric operators like `+` or comparison operators like `>=` because custom |
| 4216 |
// methods are needed to perform accurate arithmetic or comparison.) |
| 4217 |
// |
| 4218 |
// To fix the problem, coerce this object or symbol value to a string before |
| 4219 |
// passing it to React. The most reliable way is usually `String(value)`. |
| 4220 |
// |
| 4221 |
// To find which value is throwing, check the browser or debugger console. |
| 4222 |
// Before this exception was thrown, there should be `console.error` output |
| 4223 |
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the |
| 4224 |
// problem and how that type was used: key, atrribute, input value prop, etc. |
| 4225 |
// In most cases, this console output also shows the component and its |
| 4226 |
// ancestor components where the exception happened. |
| 4227 |
// |
| 4228 |
// eslint-disable-next-line react-internal/safe-string-coercion |
| 4229 |
return '' + value; |
| 4230 |
} |
| 4231 |
function checkKeyStringCoercion(value) { |
| 4232 |
{ |
| 4233 |
if (willCoercionThrow(value)) { |
| 4234 |
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value)); |
| 4235 |
|
| 4236 |
return testStringCoercion(value); // throw (to help callers find troubleshooting comments) |
| 4237 |
} |
| 4238 |
} |
| 4239 |
} |
| 4240 |
|
| 4241 |
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; |
| 4242 |
var RESERVED_PROPS = { |
| 4243 |
key: true, |
| 4244 |
ref: true, |
| 4245 |
__self: true, |
| 4246 |
__source: true |
| 4247 |
}; |
| 4248 |
var specialPropKeyWarningShown; |
| 4249 |
var specialPropRefWarningShown; |
| 4250 |
var didWarnAboutStringRefs; |
| 4251 |
|
| 4252 |
{ |
| 4253 |
didWarnAboutStringRefs = {}; |
| 4254 |
} |
| 4255 |
|
| 4256 |
function hasValidRef(config) { |
| 4257 |
{ |
| 4258 |
if (hasOwnProperty.call(config, 'ref')) { |
| 4259 |
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; |
| 4260 |
|
| 4261 |
if (getter && getter.isReactWarning) { |
| 4262 |
return false; |
| 4263 |
} |
| 4264 |
} |
| 4265 |
} |
| 4266 |
|
| 4267 |
return config.ref !== undefined; |
| 4268 |
} |
| 4269 |
|
| 4270 |
function hasValidKey(config) { |
| 4271 |
{ |
| 4272 |
if (hasOwnProperty.call(config, 'key')) { |
| 4273 |
var getter = Object.getOwnPropertyDescriptor(config, 'key').get; |
| 4274 |
|
| 4275 |
if (getter && getter.isReactWarning) { |
| 4276 |
return false; |
| 4277 |
} |
| 4278 |
} |
| 4279 |
} |
| 4280 |
|
| 4281 |
return config.key !== undefined; |
| 4282 |
} |
| 4283 |
|
| 4284 |
function warnIfStringRefCannotBeAutoConverted(config, self) { |
| 4285 |
{ |
| 4286 |
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) { |
| 4287 |
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type); |
| 4288 |
|
| 4289 |
if (!didWarnAboutStringRefs[componentName]) { |
| 4290 |
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref); |
| 4291 |
|
| 4292 |
didWarnAboutStringRefs[componentName] = true; |
| 4293 |
} |
| 4294 |
} |
| 4295 |
} |
| 4296 |
} |
| 4297 |
|
| 4298 |
function defineKeyPropWarningGetter(props, displayName) { |
| 4299 |
{ |
| 4300 |
var warnAboutAccessingKey = function () { |
| 4301 |
if (!specialPropKeyWarningShown) { |
| 4302 |
specialPropKeyWarningShown = true; |
| 4303 |
|
| 4304 |
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); |
| 4305 |
} |
| 4306 |
}; |
| 4307 |
|
| 4308 |
warnAboutAccessingKey.isReactWarning = true; |
| 4309 |
Object.defineProperty(props, 'key', { |
| 4310 |
get: warnAboutAccessingKey, |
| 4311 |
configurable: true |
| 4312 |
}); |
| 4313 |
} |
| 4314 |
} |
| 4315 |
|
| 4316 |
function defineRefPropWarningGetter(props, displayName) { |
| 4317 |
{ |
| 4318 |
var warnAboutAccessingRef = function () { |
| 4319 |
if (!specialPropRefWarningShown) { |
| 4320 |
specialPropRefWarningShown = true; |
| 4321 |
|
| 4322 |
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName); |
| 4323 |
} |
| 4324 |
}; |
| 4325 |
|
| 4326 |
warnAboutAccessingRef.isReactWarning = true; |
| 4327 |
Object.defineProperty(props, 'ref', { |
| 4328 |
get: warnAboutAccessingRef, |
| 4329 |
configurable: true |
| 4330 |
}); |
| 4331 |
} |
| 4332 |
} |
| 4333 |
/** |
| 4334 |
* Factory method to create a new React element. This no longer adheres to |
| 4335 |
* the class pattern, so do not use new to call it. Also, instanceof check |
| 4336 |
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check |
| 4337 |
* if something is a React Element. |
| 4338 |
* |
| 4339 |
* @param {*} type |
| 4340 |
* @param {*} props |
| 4341 |
* @param {*} key |
| 4342 |
* @param {string|object} ref |
| 4343 |
* @param {*} owner |
| 4344 |
* @param {*} self A *temporary* helper to detect places where `this` is |
| 4345 |
* different from the `owner` when React.createElement is called, so that we |
| 4346 |
* can warn. We want to get rid of owner and replace string `ref`s with arrow |
| 4347 |
* functions, and as long as `this` and owner are the same, there will be no |
| 4348 |
* change in behavior. |
| 4349 |
* @param {*} source An annotation object (added by a transpiler or otherwise) |
| 4350 |
* indicating filename, line number, and/or other information. |
| 4351 |
* @internal |
| 4352 |
*/ |
| 4353 |
|
| 4354 |
|
| 4355 |
var ReactElement = function (type, key, ref, self, source, owner, props) { |
| 4356 |
var element = { |
| 4357 |
// This tag allows us to uniquely identify this as a React Element |
| 4358 |
$$typeof: REACT_ELEMENT_TYPE, |
| 4359 |
// Built-in properties that belong on the element |
| 4360 |
type: type, |
| 4361 |
key: key, |
| 4362 |
ref: ref, |
| 4363 |
props: props, |
| 4364 |
// Record the component responsible for creating this element. |
| 4365 |
_owner: owner |
| 4366 |
}; |
| 4367 |
|
| 4368 |
{ |
| 4369 |
// The validation flag is currently mutative. We put it on |
| 4370 |
// an external backing store so that we can freeze the whole object. |
| 4371 |
// This can be replaced with a WeakMap once they are implemented in |
| 4372 |
// commonly used development environments. |
| 4373 |
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make |
| 4374 |
// the validation flag non-enumerable (where possible, which should |
| 4375 |
// include every environment we run tests in), so the test framework |
| 4376 |
// ignores it. |
| 4377 |
|
| 4378 |
Object.defineProperty(element._store, 'validated', { |
| 4379 |
configurable: false, |
| 4380 |
enumerable: false, |
| 4381 |
writable: true, |
| 4382 |
value: false |
| 4383 |
}); // self and source are DEV only properties. |
| 4384 |
|
| 4385 |
Object.defineProperty(element, '_self', { |
| 4386 |
configurable: false, |
| 4387 |
enumerable: false, |
| 4388 |
writable: false, |
| 4389 |
value: self |
| 4390 |
}); // Two elements created in two different places should be considered |
| 4391 |
// equal for testing purposes and therefore we hide it from enumeration. |
| 4392 |
|
| 4393 |
Object.defineProperty(element, '_source', { |
| 4394 |
configurable: false, |
| 4395 |
enumerable: false, |
| 4396 |
writable: false, |
| 4397 |
value: source |
| 4398 |
}); |
| 4399 |
|
| 4400 |
if (Object.freeze) { |
| 4401 |
Object.freeze(element.props); |
| 4402 |
Object.freeze(element); |
| 4403 |
} |
| 4404 |
} |
| 4405 |
|
| 4406 |
return element; |
| 4407 |
}; |
| 4408 |
/** |
| 4409 |
* https://github.com/reactjs/rfcs/pull/107 |
| 4410 |
* @param {*} type |
| 4411 |
* @param {object} props |
| 4412 |
* @param {string} key |
| 4413 |
*/ |
| 4414 |
|
| 4415 |
function jsxDEV(type, config, maybeKey, source, self) { |
| 4416 |
{ |
| 4417 |
var propName; // Reserved names are extracted |
| 4418 |
|
| 4419 |
var props = {}; |
| 4420 |
var key = null; |
| 4421 |
var ref = null; // Currently, key can be spread in as a prop. This causes a potential |
| 4422 |
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" /> |
| 4423 |
// or <div key="Hi" {...props} /> ). We want to deprecate key spread, |
| 4424 |
// but as an intermediary step, we will use jsxDEV for everything except |
| 4425 |
// <div {...props} key="Hi" />, because we aren't currently able to tell if |
| 4426 |
// key is explicitly declared to be undefined or not. |
| 4427 |
|
| 4428 |
if (maybeKey !== undefined) { |
| 4429 |
{ |
| 4430 |
checkKeyStringCoercion(maybeKey); |
| 4431 |
} |
| 4432 |
|
| 4433 |
key = '' + maybeKey; |
| 4434 |
} |
| 4435 |
|
| 4436 |
if (hasValidKey(config)) { |
| 4437 |
{ |
| 4438 |
checkKeyStringCoercion(config.key); |
| 4439 |
} |
| 4440 |
|
| 4441 |
key = '' + config.key; |
| 4442 |
} |
| 4443 |
|
| 4444 |
if (hasValidRef(config)) { |
| 4445 |
ref = config.ref; |
| 4446 |
warnIfStringRefCannotBeAutoConverted(config, self); |
| 4447 |
} // Remaining properties are added to a new props object |
| 4448 |
|
| 4449 |
|
| 4450 |
for (propName in config) { |
| 4451 |
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
| 4452 |
props[propName] = config[propName]; |
| 4453 |
} |
| 4454 |
} // Resolve default props |
| 4455 |
|
| 4456 |
|
| 4457 |
if (type && type.defaultProps) { |
| 4458 |
var defaultProps = type.defaultProps; |
| 4459 |
|
| 4460 |
for (propName in defaultProps) { |
| 4461 |
if (props[propName] === undefined) { |
| 4462 |
props[propName] = defaultProps[propName]; |
| 4463 |
} |
| 4464 |
} |
| 4465 |
} |
| 4466 |
|
| 4467 |
if (key || ref) { |
| 4468 |
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; |
| 4469 |
|
| 4470 |
if (key) { |
| 4471 |
defineKeyPropWarningGetter(props, displayName); |
| 4472 |
} |
| 4473 |
|
| 4474 |
if (ref) { |
| 4475 |
defineRefPropWarningGetter(props, displayName); |
| 4476 |
} |
| 4477 |
} |
| 4478 |
|
| 4479 |
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); |
| 4480 |
} |
| 4481 |
} |
| 4482 |
|
| 4483 |
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; |
| 4484 |
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; |
| 4485 |
|
| 4486 |
function setCurrentlyValidatingElement$1(element) { |
| 4487 |
{ |
| 4488 |
if (element) { |
| 4489 |
var owner = element._owner; |
| 4490 |
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null); |
| 4491 |
ReactDebugCurrentFrame$1.setExtraStackFrame(stack); |
| 4492 |
} else { |
| 4493 |
ReactDebugCurrentFrame$1.setExtraStackFrame(null); |
| 4494 |
} |
| 4495 |
} |
| 4496 |
} |
| 4497 |
|
| 4498 |
var propTypesMisspellWarningShown; |
| 4499 |
|
| 4500 |
{ |
| 4501 |
propTypesMisspellWarningShown = false; |
| 4502 |
} |
| 4503 |
/** |
| 4504 |
* Verifies the object is a ReactElement. |
| 4505 |
* See https://reactjs.org/docs/react-api.html#isvalidelement |
| 4506 |
* @param {?object} object |
| 4507 |
* @return {boolean} True if `object` is a ReactElement. |
| 4508 |
* @final |
| 4509 |
*/ |
| 4510 |
|
| 4511 |
|
| 4512 |
function isValidElement(object) { |
| 4513 |
{ |
| 4514 |
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; |
| 4515 |
} |
| 4516 |
} |
| 4517 |
|
| 4518 |
function getDeclarationErrorAddendum() { |
| 4519 |
{ |
| 4520 |
if (ReactCurrentOwner$1.current) { |
| 4521 |
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type); |
| 4522 |
|
| 4523 |
if (name) { |
| 4524 |
return '\n\nCheck the render method of `' + name + '`.'; |
| 4525 |
} |
| 4526 |
} |
| 4527 |
|
| 4528 |
return ''; |
| 4529 |
} |
| 4530 |
} |
| 4531 |
|
| 4532 |
function getSourceInfoErrorAddendum(source) { |
| 4533 |
{ |
| 4534 |
if (source !== undefined) { |
| 4535 |
var fileName = source.fileName.replace(/^.*[\\\/]/, ''); |
| 4536 |
var lineNumber = source.lineNumber; |
| 4537 |
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; |
| 4538 |
} |
| 4539 |
|
| 4540 |
return ''; |
| 4541 |
} |
| 4542 |
} |
| 4543 |
/** |
| 4544 |
* Warn if there's no key explicitly set on dynamic arrays of children or |
| 4545 |
* object keys are not valid. This allows us to keep track of children between |
| 4546 |
* updates. |
| 4547 |
*/ |
| 4548 |
|
| 4549 |
|
| 4550 |
var ownerHasKeyUseWarning = {}; |
| 4551 |
|
| 4552 |
function getCurrentComponentErrorInfo(parentType) { |
| 4553 |
{ |
| 4554 |
var info = getDeclarationErrorAddendum(); |
| 4555 |
|
| 4556 |
if (!info) { |
| 4557 |
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; |
| 4558 |
|
| 4559 |
if (parentName) { |
| 4560 |
info = "\n\nCheck the top-level render call using <" + parentName + ">."; |
| 4561 |
} |
| 4562 |
} |
| 4563 |
|
| 4564 |
return info; |
| 4565 |
} |
| 4566 |
} |
| 4567 |
/** |
| 4568 |
* Warn if the element doesn't have an explicit key assigned to it. |
| 4569 |
* This element is in an array. The array could grow and shrink or be |
| 4570 |
* reordered. All children that haven't already been validated are required to |
| 4571 |
* have a "key" property assigned to it. Error statuses are cached so a warning |
| 4572 |
* will only be shown once. |
| 4573 |
* |
| 4574 |
* @internal |
| 4575 |
* @param {ReactElement} element Element that requires a key. |
| 4576 |
* @param {*} parentType element's parent's type. |
| 4577 |
*/ |
| 4578 |
|
| 4579 |
|
| 4580 |
function validateExplicitKey(element, parentType) { |
| 4581 |
{ |
| 4582 |
if (!element._store || element._store.validated || element.key != null) { |
| 4583 |
return; |
| 4584 |
} |
| 4585 |
|
| 4586 |
element._store.validated = true; |
| 4587 |
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); |
| 4588 |
|
| 4589 |
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { |
| 4590 |
return; |
| 4591 |
} |
| 4592 |
|
| 4593 |
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a |
| 4594 |
// property, it may be the creator of the child that's responsible for |
| 4595 |
// assigning it a key. |
| 4596 |
|
| 4597 |
var childOwner = ''; |
| 4598 |
|
| 4599 |
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) { |
| 4600 |
// Give the component that originally created this child. |
| 4601 |
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + "."; |
| 4602 |
} |
| 4603 |
|
| 4604 |
setCurrentlyValidatingElement$1(element); |
| 4605 |
|
| 4606 |
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); |
| 4607 |
|
| 4608 |
setCurrentlyValidatingElement$1(null); |
| 4609 |
} |
| 4610 |
} |
| 4611 |
/** |
| 4612 |
* Ensure that every element either is passed in a static location, in an |
| 4613 |
* array with an explicit keys property defined, or in an object literal |
| 4614 |
* with valid key property. |
| 4615 |
* |
| 4616 |
* @internal |
| 4617 |
* @param {ReactNode} node Statically passed child of any type. |
| 4618 |
* @param {*} parentType node's parent's type. |
| 4619 |
*/ |
| 4620 |
|
| 4621 |
|
| 4622 |
function validateChildKeys(node, parentType) { |
| 4623 |
{ |
| 4624 |
if (typeof node !== 'object') { |
| 4625 |
return; |
| 4626 |
} |
| 4627 |
|
| 4628 |
if (isArray(node)) { |
| 4629 |
for (var i = 0; i < node.length; i++) { |
| 4630 |
var child = node[i]; |
| 4631 |
|
| 4632 |
if (isValidElement(child)) { |
| 4633 |
validateExplicitKey(child, parentType); |
| 4634 |
} |
| 4635 |
} |
| 4636 |
} else if (isValidElement(node)) { |
| 4637 |
// This element was passed in a valid location. |
| 4638 |
if (node._store) { |
| 4639 |
node._store.validated = true; |
| 4640 |
} |
| 4641 |
} else if (node) { |
| 4642 |
var iteratorFn = getIteratorFn(node); |
| 4643 |
|
| 4644 |
if (typeof iteratorFn === 'function') { |
| 4645 |
// Entry iterators used to provide implicit keys, |
| 4646 |
// but now we print a separate warning for them later. |
| 4647 |
if (iteratorFn !== node.entries) { |
| 4648 |
var iterator = iteratorFn.call(node); |
| 4649 |
var step; |
| 4650 |
|
| 4651 |
while (!(step = iterator.next()).done) { |
| 4652 |
if (isValidElement(step.value)) { |
| 4653 |
validateExplicitKey(step.value, parentType); |
| 4654 |
} |
| 4655 |
} |
| 4656 |
} |
| 4657 |
} |
| 4658 |
} |
| 4659 |
} |
| 4660 |
} |
| 4661 |
/** |
| 4662 |
* Given an element, validate that its props follow the propTypes definition, |
| 4663 |
* provided by the type. |
| 4664 |
* |
| 4665 |
* @param {ReactElement} element |
| 4666 |
*/ |
| 4667 |
|
| 4668 |
|
| 4669 |
function validatePropTypes(element) { |
| 4670 |
{ |
| 4671 |
var type = element.type; |
| 4672 |
|
| 4673 |
if (type === null || type === undefined || typeof type === 'string') { |
| 4674 |
return; |
| 4675 |
} |
| 4676 |
|
| 4677 |
var propTypes; |
| 4678 |
|
| 4679 |
if (typeof type === 'function') { |
| 4680 |
propTypes = type.propTypes; |
| 4681 |
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. |
| 4682 |
// Inner props are checked in the reconciler. |
| 4683 |
type.$$typeof === REACT_MEMO_TYPE)) { |
| 4684 |
propTypes = type.propTypes; |
| 4685 |
} else { |
| 4686 |
return; |
| 4687 |
} |
| 4688 |
|
| 4689 |
if (propTypes) { |
| 4690 |
// Intentionally inside to avoid triggering lazy initializers: |
| 4691 |
var name = getComponentNameFromType(type); |
| 4692 |
checkPropTypes(propTypes, element.props, 'prop', name, element); |
| 4693 |
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { |
| 4694 |
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers: |
| 4695 |
|
| 4696 |
var _name = getComponentNameFromType(type); |
| 4697 |
|
| 4698 |
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown'); |
| 4699 |
} |
| 4700 |
|
| 4701 |
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) { |
| 4702 |
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); |
| 4703 |
} |
| 4704 |
} |
| 4705 |
} |
| 4706 |
/** |
| 4707 |
* Given a fragment, validate that it can only be provided with fragment props |
| 4708 |
* @param {ReactElement} fragment |
| 4709 |
*/ |
| 4710 |
|
| 4711 |
|
| 4712 |
function validateFragmentProps(fragment) { |
| 4713 |
{ |
| 4714 |
var keys = Object.keys(fragment.props); |
| 4715 |
|
| 4716 |
for (var i = 0; i < keys.length; i++) { |
| 4717 |
var key = keys[i]; |
| 4718 |
|
| 4719 |
if (key !== 'children' && key !== 'key') { |
| 4720 |
setCurrentlyValidatingElement$1(fragment); |
| 4721 |
|
| 4722 |
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); |
| 4723 |
|
| 4724 |
setCurrentlyValidatingElement$1(null); |
| 4725 |
break; |
| 4726 |
} |
| 4727 |
} |
| 4728 |
|
| 4729 |
if (fragment.ref !== null) { |
| 4730 |
setCurrentlyValidatingElement$1(fragment); |
| 4731 |
|
| 4732 |
error('Invalid attribute `ref` supplied to `React.Fragment`.'); |
| 4733 |
|
| 4734 |
setCurrentlyValidatingElement$1(null); |
| 4735 |
} |
| 4736 |
} |
| 4737 |
} |
| 4738 |
|
| 4739 |
var didWarnAboutKeySpread = {}; |
| 4740 |
function jsxWithValidation(type, props, key, isStaticChildren, source, self) { |
| 4741 |
{ |
| 4742 |
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to |
| 4743 |
// succeed and there will likely be errors in render. |
| 4744 |
|
| 4745 |
if (!validType) { |
| 4746 |
var info = ''; |
| 4747 |
|
| 4748 |
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { |
| 4749 |
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; |
| 4750 |
} |
| 4751 |
|
| 4752 |
var sourceInfo = getSourceInfoErrorAddendum(source); |
| 4753 |
|
| 4754 |
if (sourceInfo) { |
| 4755 |
info += sourceInfo; |
| 4756 |
} else { |
| 4757 |
info += getDeclarationErrorAddendum(); |
| 4758 |
} |
| 4759 |
|
| 4760 |
var typeString; |
| 4761 |
|
| 4762 |
if (type === null) { |
| 4763 |
typeString = 'null'; |
| 4764 |
} else if (isArray(type)) { |
| 4765 |
typeString = 'array'; |
| 4766 |
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { |
| 4767 |
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />"; |
| 4768 |
info = ' Did you accidentally export a JSX literal instead of a component?'; |
| 4769 |
} else { |
| 4770 |
typeString = typeof type; |
| 4771 |
} |
| 4772 |
|
| 4773 |
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); |
| 4774 |
} |
| 4775 |
|
| 4776 |
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used. |
| 4777 |
// TODO: Drop this when these are no longer allowed as the type argument. |
| 4778 |
|
| 4779 |
if (element == null) { |
| 4780 |
return element; |
| 4781 |
} // Skip key warning if the type isn't valid since our key validation logic |
| 4782 |
// doesn't expect a non-string/function type and can throw confusing errors. |
| 4783 |
// We don't want exception behavior to differ between dev and prod. |
| 4784 |
// (Rendering will throw with a helpful message and as soon as the type is |
| 4785 |
// fixed, the key warnings will appear.) |
| 4786 |
|
| 4787 |
|
| 4788 |
if (validType) { |
| 4789 |
var children = props.children; |
| 4790 |
|
| 4791 |
if (children !== undefined) { |
| 4792 |
if (isStaticChildren) { |
| 4793 |
if (isArray(children)) { |
| 4794 |
for (var i = 0; i < children.length; i++) { |
| 4795 |
validateChildKeys(children[i], type); |
| 4796 |
} |
| 4797 |
|
| 4798 |
if (Object.freeze) { |
| 4799 |
Object.freeze(children); |
| 4800 |
} |
| 4801 |
} else { |
| 4802 |
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.'); |
| 4803 |
} |
| 4804 |
} else { |
| 4805 |
validateChildKeys(children, type); |
| 4806 |
} |
| 4807 |
} |
| 4808 |
} |
| 4809 |
|
| 4810 |
{ |
| 4811 |
if (hasOwnProperty.call(props, 'key')) { |
| 4812 |
var componentName = getComponentNameFromType(type); |
| 4813 |
var keys = Object.keys(props).filter(function (k) { |
| 4814 |
return k !== 'key'; |
| 4815 |
}); |
| 4816 |
var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}'; |
| 4817 |
|
| 4818 |
if (!didWarnAboutKeySpread[componentName + beforeExample]) { |
| 4819 |
var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}'; |
| 4820 |
|
| 4821 |
error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName); |
| 4822 |
|
| 4823 |
didWarnAboutKeySpread[componentName + beforeExample] = true; |
| 4824 |
} |
| 4825 |
} |
| 4826 |
} |
| 4827 |
|
| 4828 |
if (type === REACT_FRAGMENT_TYPE) { |
| 4829 |
validateFragmentProps(element); |
| 4830 |
} else { |
| 4831 |
validatePropTypes(element); |
| 4832 |
} |
| 4833 |
|
| 4834 |
return element; |
| 4835 |
} |
| 4836 |
} // These two functions exist to still get child warnings in dev |
| 4837 |
// even with the prod transform. This means that jsxDEV is purely |
| 4838 |
// opt-in behavior for better messages but that we won't stop |
| 4839 |
// giving you warnings if you use production apis. |
| 4840 |
|
| 4841 |
function jsxWithValidationStatic(type, props, key) { |
| 4842 |
{ |
| 4843 |
return jsxWithValidation(type, props, key, true); |
| 4844 |
} |
| 4845 |
} |
| 4846 |
function jsxWithValidationDynamic(type, props, key) { |
| 4847 |
{ |
| 4848 |
return jsxWithValidation(type, props, key, false); |
| 4849 |
} |
| 4850 |
} |
| 4851 |
|
| 4852 |
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children. |
| 4853 |
// for now we can ship identical prod functions |
| 4854 |
|
| 4855 |
var jsxs = jsxWithValidationStatic ; |
| 4856 |
|
| 4857 |
exports.Fragment = REACT_FRAGMENT_TYPE; |
| 4858 |
exports.jsx = jsx; |
| 4859 |
exports.jsxs = jsxs; |
| 4860 |
})(); |
| 4861 |
} |
| 4862 |
|
| 4863 |
|
| 4864 |
/***/ }), |
| 4865 |
|
| 4866 |
/***/ "./node_modules/react/jsx-runtime.js": |
| 4867 |
/*!*******************************************!*\ |
| 4868 |
!*** ./node_modules/react/jsx-runtime.js ***! |
| 4869 |
\*******************************************/ |
| 4870 |
/***/ (function(module, __unused_webpack_exports, __webpack_require__) { |
| 4871 |
|
| 4872 |
|
| 4873 |
|
| 4874 |
if (false) // removed by dead control flow |
| 4875 |
{} else { |
| 4876 |
module.exports = __webpack_require__(/*! ./cjs/react-jsx-runtime.development.js */ "./node_modules/react/cjs/react-jsx-runtime.development.js"); |
| 4877 |
} |
| 4878 |
|
| 4879 |
|
| 4880 |
/***/ }), |
| 4881 |
|
| 4882 |
/***/ "react": |
| 4883 |
/*!**************************!*\ |
| 4884 |
!*** external ["React"] ***! |
| 4885 |
\**************************/ |
| 4886 |
/***/ (function(module) { |
| 4887 |
|
| 4888 |
module.exports = window["React"]; |
| 4889 |
|
| 4890 |
/***/ }) |
| 4891 |
|
| 4892 |
/******/ }); |
| 4893 |
/************************************************************************/ |
| 4894 |
/******/ // The module cache |
| 4895 |
/******/ var __webpack_module_cache__ = {}; |
| 4896 |
/******/ |
| 4897 |
/******/ // The require function |
| 4898 |
/******/ function __webpack_require__(moduleId) { |
| 4899 |
/******/ // Check if module is in cache |
| 4900 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 4901 |
/******/ if (cachedModule !== undefined) { |
| 4902 |
/******/ return cachedModule.exports; |
| 4903 |
/******/ } |
| 4904 |
/******/ // Create a new module (and put it into the cache) |
| 4905 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 4906 |
/******/ // no module.id needed |
| 4907 |
/******/ // no module.loaded needed |
| 4908 |
/******/ exports: {} |
| 4909 |
/******/ }; |
| 4910 |
/******/ |
| 4911 |
/******/ // Execute the module function |
| 4912 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 4913 |
/******/ |
| 4914 |
/******/ // Return the exports of the module |
| 4915 |
/******/ return module.exports; |
| 4916 |
/******/ } |
| 4917 |
/******/ |
| 4918 |
/************************************************************************/ |
| 4919 |
/******/ /* webpack/runtime/define property getters */ |
| 4920 |
/******/ !function() { |
| 4921 |
/******/ // define getter functions for harmony exports |
| 4922 |
/******/ __webpack_require__.d = function(exports, definition) { |
| 4923 |
/******/ for(var key in definition) { |
| 4924 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 4925 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 4926 |
/******/ } |
| 4927 |
/******/ } |
| 4928 |
/******/ }; |
| 4929 |
/******/ }(); |
| 4930 |
/******/ |
| 4931 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 4932 |
/******/ !function() { |
| 4933 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
| 4934 |
/******/ }(); |
| 4935 |
/******/ |
| 4936 |
/******/ /* webpack/runtime/make namespace object */ |
| 4937 |
/******/ !function() { |
| 4938 |
/******/ // define __esModule on exports |
| 4939 |
/******/ __webpack_require__.r = function(exports) { |
| 4940 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 4941 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 4942 |
/******/ } |
| 4943 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 4944 |
/******/ }; |
| 4945 |
/******/ }(); |
| 4946 |
/******/ |
| 4947 |
/************************************************************************/ |
| 4948 |
var __webpack_exports__ = {}; |
| 4949 |
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. |
| 4950 |
!function() { |
| 4951 |
/*!***************************************************!*\ |
| 4952 |
!*** ./packages/packages/libs/query/src/index.ts ***! |
| 4953 |
\***************************************************/ |
| 4954 |
__webpack_require__.r(__webpack_exports__); |
| 4955 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 4956 |
/* harmony export */ QueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient; }, |
| 4957 |
/* harmony export */ QueryClientProvider: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__.QueryClientProvider; }, |
| 4958 |
/* harmony export */ createQueryClient: function() { return /* binding */ createQueryClient; }, |
| 4959 |
/* harmony export */ getQueryClient: function() { return /* binding */ getQueryClient; }, |
| 4960 |
/* harmony export */ useInfiniteQuery: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.useInfiniteQuery; }, |
| 4961 |
/* harmony export */ useIsMutating: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__.useIsMutating; }, |
| 4962 |
/* harmony export */ useMutation: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_4__.useMutation; }, |
| 4963 |
/* harmony export */ useQuery: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__.useQuery; }, |
| 4964 |
/* harmony export */ useQueryClient: function() { return /* reexport safe */ _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__.useQueryClient; } |
| 4965 |
/* harmony export */ }); |
| 4966 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/query-core/build/modern/queryClient.js"); |
| 4967 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useQuery.js"); |
| 4968 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"); |
| 4969 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useMutationState.js"); |
| 4970 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useMutation.js"); |
| 4971 |
/* harmony import */ var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @tanstack/react-query */ "./node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js"); |
| 4972 |
|
| 4973 |
|
| 4974 |
let queryClient; |
| 4975 |
function getQueryClient() { |
| 4976 |
if (!queryClient) { |
| 4977 |
throw new Error('Query client is not created yet.'); |
| 4978 |
} |
| 4979 |
return queryClient; |
| 4980 |
} |
| 4981 |
function createQueryClient() { |
| 4982 |
if (queryClient) { |
| 4983 |
throw new Error('Query client is already created.'); |
| 4984 |
} |
| 4985 |
queryClient = new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.QueryClient({ |
| 4986 |
defaultOptions: { |
| 4987 |
queries: { |
| 4988 |
refetchOnWindowFocus: false, |
| 4989 |
refetchOnReconnect: false |
| 4990 |
} |
| 4991 |
} |
| 4992 |
}); |
| 4993 |
return queryClient; |
| 4994 |
} |
| 4995 |
}(); |
| 4996 |
(window.elementorV2 = window.elementorV2 || {}).query = __webpack_exports__; |
| 4997 |
/******/ })() |
| 4998 |
; |
| 4999 |
window.elementorV2.query?.init?.(); |
| 5000 |
//# sourceMappingURL=query.js.map |