@gen-epix/ui-client-common 4.7.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/CrudPage.js +236 -235
- package/dist/_chunks/CrudPage.js.map +1 -1
- package/dist/_chunks/GeoFilter.js +2 -1
- package/dist/_chunks/GeoFilter.js.map +1 -1
- package/dist/_chunks/QueryClientProvider.js +1 -1
- package/dist/_chunks/QueryClientProvider.js.map +1 -1
- package/dist/_chunks/QueryClientService.js +39 -35
- package/dist/_chunks/QueryClientService.js.map +1 -1
- package/dist/_chunks/Table.js +1048 -714
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/TableUtil.js +5187 -230
- package/dist/_chunks/TableUtil.js.map +1 -1
- package/dist/_chunks/TextFilter.js +51 -38
- package/dist/_chunks/TextFilter.js.map +1 -1
- package/dist/_chunks/UserInvitationsAdminPage.js +3 -3
- package/dist/_chunks/UserInvitationsAdminPage.js.map +1 -1
- package/dist/_chunks/{_cacheHas.js → _arrayIncludesWith.js} +17 -17
- package/dist/_chunks/_arrayIncludesWith.js.map +1 -0
- package/dist/_chunks/{isArrayLike.js → _arrayMap.js} +94 -94
- package/dist/_chunks/_arrayMap.js.map +1 -0
- package/dist/_chunks/_baseGet.js +61 -61
- package/dist/_chunks/_baseGet.js.map +1 -1
- package/dist/_chunks/_baseIteratee.js +28 -28
- package/dist/_chunks/_baseIteratee.js.map +1 -1
- package/dist/_chunks/_setToString.js +7 -7
- package/dist/_chunks/_setToString.js.map +1 -1
- package/dist/_chunks/middleware.js +1 -1
- package/dist/_chunks/middleware.js.map +1 -1
- package/dist/_chunks/omit.js +74 -58
- package/dist/_chunks/omit.js.map +1 -1
- package/dist/_chunks/query.js +271 -269
- package/dist/_chunks/query.js.map +1 -1
- package/dist/_chunks/react.js +1 -1
- package/dist/_chunks/react.js.map +1 -1
- package/dist/_chunks/tableStore.js +291 -246
- package/dist/_chunks/tableStore.js.map +1 -1
- package/dist/_chunks/uniq.js +2 -2
- package/dist/_chunks/uniq.js.map +1 -1
- package/dist/_chunks/useMutation.js +17 -17
- package/dist/_chunks/useMutation.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +103 -103
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/_chunks/vanilla.js +1 -1
- package/dist/_chunks/vanilla.js.map +1 -1
- package/dist/_chunks/yup.js +2 -2
- package/dist/_chunks/yup.js.map +1 -1
- package/dist/classes/abstracts/FilterAbstract/FilterAbstract.d.ts +11 -0
- package/dist/classes/abstracts/FilterAbstract/index.js +48 -3
- package/dist/classes/abstracts/FilterAbstract/index.js.map +1 -1
- package/dist/classes/filters/BooleanFilter.d.ts +1 -0
- package/dist/classes/filters/DateFilter.d.ts +1 -1
- package/dist/classes/filters/GeoFilter.d.ts +1 -0
- package/dist/classes/filters/MultiSelectFilter.d.ts +9 -6
- package/dist/classes/filters/NumberRangeFilter.d.ts +1 -0
- package/dist/classes/filters/TextFilter.d.ts +1 -0
- package/dist/classes/services/EmotionCacheService/index.js +3 -1
- package/dist/classes/services/EmotionCacheService/index.js.map +1 -1
- package/dist/components/app/App/index.js +4 -3
- package/dist/components/app/App/index.js.map +1 -1
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js +1 -1
- package/dist/components/app/ApplicationBootstrapWithAuthentication/index.js.map +1 -1
- package/dist/components/ui/ApplicationBar/index.js +2 -0
- package/dist/components/ui/ApplicationBar/index.js.map +1 -1
- package/dist/components/ui/GenericErrorMessage/index.js +1 -0
- package/dist/components/ui/GenericErrorMessage/index.js.map +1 -1
- package/dist/components/ui/OrganizationSwitcherDialog/index.js +1 -1
- package/dist/components/ui/OrganizationSwitcherDialog/index.js.map +1 -1
- package/dist/components/ui/Table/TableDownloadSidebarItem.d.ts +10 -0
- package/dist/components/ui/Table/TableSidebarMenu.d.ts +2 -1
- package/dist/components/ui/Table/index.d.ts +1 -0
- package/dist/components/ui/Table/index.js +1 -1
- package/dist/components/ui/Table/useTableColumnsMenu.d.ts +6 -0
- package/dist/dataHooks/useSitesQuery/index.d.ts +1 -0
- package/dist/dataHooks/useSitesQuery/index.js +18 -0
- package/dist/dataHooks/useSitesQuery/index.js.map +1 -0
- package/dist/dataHooks/useSitesQuery/useSitesQuery.d.ts +5 -0
- package/dist/locale/en.json +16 -0
- package/dist/locale/nl.json +16 -0
- package/dist/models/table.models.d.ts +2 -1
- package/dist/models/table.models.js.map +1 -1
- package/dist/pages/CrudPage/CrudPage.d.ts +1 -1
- package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js +12 -11
- package/dist/pages/OrganizationAdminPoliciesAdminPage/index.js.map +1 -1
- package/dist/pages/OutagesAdminPage/index.js +55 -55
- package/dist/pages/OutagesAdminPage/index.js.map +1 -1
- package/dist/pages/UsersAdminPage/index.js +90 -90
- package/dist/pages/UsersAdminPage/index.js.map +1 -1
- package/dist/stores/tableStore/tableStore.d.ts +3 -1
- package/dist/theme/demoTheme/index.js +1 -1
- package/dist/theme/demoTheme/index.js.map +1 -1
- package/dist/utils/TableUtil/TableUtil.d.ts +13 -1
- package/package.json +38 -34
- package/dist/_chunks/_baseFlatten.js +0 -26
- package/dist/_chunks/_baseFlatten.js.map +0 -1
- package/dist/_chunks/_cacheHas.js.map +0 -1
- package/dist/_chunks/isArrayLike.js.map +0 -1
- package/dist/_chunks/useColumnsMenu.js +0 -159
- package/dist/_chunks/useColumnsMenu.js.map +0 -1
- package/dist/hooks/useColumnsMenu/index.d.ts +0 -1
- package/dist/hooks/useColumnsMenu/index.js +0 -1
- package/dist/hooks/useColumnsMenu/useColumnsMenu.d.ts +0 -6
- package/dist/test/lib/index.d.ts +0 -1
- package/dist/test/lib/render.d.ts +0 -2
package/dist/_chunks/uniq.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime.js";
|
|
2
|
-
import { i as t, n, r, t as i } from "./
|
|
2
|
+
import { i as t, n, r, t as i } from "./_arrayIncludesWith.js";
|
|
3
3
|
import { o as a } from "./_baseGet.js";
|
|
4
4
|
import { n as o } from "./_baseIteratee.js";
|
|
5
5
|
// ../../node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/noop.js
|
|
@@ -12,7 +12,7 @@ var s = /* @__PURE__ */ e(((e, t) => {
|
|
|
12
12
|
return new n(e);
|
|
13
13
|
} : r;
|
|
14
14
|
})), l = /* @__PURE__ */ e(((e, a) => {
|
|
15
|
-
var s = t(), l =
|
|
15
|
+
var s = t(), l = n(), u = i(), d = r(), f = c(), p = o(), m = 200;
|
|
16
16
|
function h(e, t, n) {
|
|
17
17
|
var r = -1, i = l, a = e.length, o = !0, c = [], h = c;
|
|
18
18
|
if (n) o = !1, i = u;
|
package/dist/_chunks/uniq.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniq.js","names":["__commonJSMin","require__SetCache","
|
|
1
|
+
{"version":3,"file":"uniq.js","names":["__commonJSMin","require__SetCache","require__arrayIncludesWith","require__Set","require__setToArray","require_noop","noop","require__createSet","Set","setToArray","values","require__baseUniq","SetCache","arrayIncludes","require__arrayIncludes","arrayIncludesWith","cacheHas","require__cacheHas","createSet","LARGE_ARRAY_SIZE","baseUniq","index","includes","length","array","isCommon","result","seen","comparator","set","iteratee","value","computed","seenIndex","require_uniq","uniq"],"sources":["../../../../node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/noop.js","../../../../node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_createSet.js","../../../../node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_baseUniq.js","../../../../node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/uniq.js"],"sourcesContent":["/**\n * This method returns `undefined`.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Util\n * @example\n *\n * _.times(2, _.noop);\n * // => [undefined, undefined]\n */\nfunction noop() {\n // No operation performed.\n}\n\nmodule.exports = noop;\n","var Set = require('./_Set'),\n noop = require('./noop'),\n setToArray = require('./_setToArray');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/**\n * Creates a set object of `values`.\n *\n * @private\n * @param {Array} values The values to add to the set.\n * @returns {Object} Returns the new set.\n */\nvar createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {\n return new Set(values);\n};\n\nmodule.exports = createSet;\n","var SetCache = require('./_SetCache'),\n arrayIncludes = require('./_arrayIncludes'),\n arrayIncludesWith = require('./_arrayIncludesWith'),\n cacheHas = require('./_cacheHas'),\n createSet = require('./_createSet'),\n setToArray = require('./_setToArray');\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * The base implementation of `_.uniqBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new duplicate free array.\n */\nfunction baseUniq(array, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n length = array.length,\n isCommon = true,\n result = [],\n seen = result;\n\n if (comparator) {\n isCommon = false;\n includes = arrayIncludesWith;\n }\n else if (length >= LARGE_ARRAY_SIZE) {\n var set = iteratee ? null : createSet(array);\n if (set) {\n return setToArray(set);\n }\n isCommon = false;\n includes = cacheHas;\n seen = new SetCache;\n }\n else {\n seen = iteratee ? [] : result;\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var seenIndex = seen.length;\n while (seenIndex--) {\n if (seen[seenIndex] === computed) {\n continue outer;\n }\n }\n if (iteratee) {\n seen.push(computed);\n }\n result.push(value);\n }\n else if (!includes(seen, computed, comparator)) {\n if (seen !== result) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n}\n\nmodule.exports = baseUniq;\n","var baseUniq = require('./_baseUniq');\n\n/**\n * Creates a duplicate-free version of an array, using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons, in which only the first occurrence of each element\n * is kept. The order of result values is determined by the order they occur\n * in the array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @returns {Array} Returns the new duplicate free array.\n * @example\n *\n * _.uniq([2, 1, 2]);\n * // => [2, 1]\n */\nfunction uniq(array) {\n return (array && array.length) ? baseUniq(array) : [];\n}\n\nmodule.exports = uniq;\n"],"ignoreList":[0,1,2,3],"mappings":";;;;;;CAYA,SAASM,IAAO,CAEhB;CAEA,EAAO,UAAUA;;CChBjB,IAAIE,IAAAL,EAAA,GACAG,IAAAD,EAAA,GACAI,IAAAL,EAAA;CAgBJ,EAAO,UAJWI,KAAQ,IAAIC,EAAW,IAAID,EAAI,GAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAT1C,IAAI,IASgE,SAAS,GAAQ;EAClG,OAAO,IAAIA,EAAIE,CAAM;CACvB,IAF4EJ;;CCd5E,IAAIM,IAAAX,EAAA,GACAY,IAAAC,EAAA,GACAC,IAAAb,EAAA,GACAc,IAAAC,EAAA,GACAC,IAAAX,EAAA,GACAE,IAAAL,EAAA,GAGAe,IAAmB;CAWvB,SAASC,EAAS,GAAO,GAAU,GAAY;EAC7C,IAAIC,IAAQ,IACRC,IAAWT,GACXU,IAASC,EAAM,QACfC,IAAW,IACXC,IAAS,CAAC,GACVC,IAAOD;EAEX,IAAIE,GAEF,AADA,IAAW,IACX,IAAWb;OAER,IAAIQ,KAAUJ,GAAkB;GACnC,IAAIU,IAAMC,IAAW,OAAOZ,EAAUM,CAAK;GAC3C,IAAIK,GACF,OAAOpB,EAAWoB,CAAG;GAIvB,AAFA,IAAW,IACX,IAAWb,GACX,IAAO,IAAIJ,EAAO;EACpB,OAEE,IAAOkB,IAAW,CAAC,IAAIJ;EAEzB,OACA,OAAO,EAAEL,IAAQE,IAAQ;GACvB,IAAIQ,IAAQP,EAAMH,IACdW,IAAWF,IAAWA,EAASC,CAAK,IAAIA;GAG5C,IADA,IAASH,KAAcG,MAAU,IAAKA,IAAQ,GAC1CN,KAAYO,MAAaA,GAAU;IAErC,KADA,IAAIC,IAAYN,EAAK,QACd,MACL,IAAIA,EAAKM,OAAeD,GACtB,SAAS;IAMb,AAHIF,KACFH,EAAK,KAAKK,CAAQ,GAEpBN,EAAO,KAAKK,CAAK;GACnB,OACK,AAAKT,EAASK,GAAMK,GAAUJ,CAAU,MACvCD,MAASD,KACXC,EAAK,KAAKK,CAAQ,GAEpBN,EAAO,KAAKK,CAAK;EAErB;EACA,OAAOL;CACT;CAEA,EAAO,UAAUN;;CCvEjB,IAAIA,IAAAT,EAAA;CAoBJ,SAASwB,EAAK,GAAO;EACnB,OAAQX,KAASA,EAAM,SAAUJ,EAASI,CAAK,IAAI,CAAC;CACtD;CAEA,EAAO,UAAUW"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as e } from "./QueryClientProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as s } from "./
|
|
2
|
+
import { n as t } from "./QueryClientService.js";
|
|
3
|
+
import { l as n, m as r, o as i, v as a, w as o, y as s } from "./query.js";
|
|
4
4
|
import * as c from "react";
|
|
5
|
-
// ../../node_modules/.pnpm/@tanstack+query-core@5.
|
|
6
|
-
var l = class extends
|
|
5
|
+
// ../../node_modules/.pnpm/@tanstack+query-core@5.108.4/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
|
|
6
|
+
var l = class extends o {
|
|
7
7
|
#e;
|
|
8
8
|
#t = void 0;
|
|
9
9
|
#n;
|
|
@@ -15,12 +15,12 @@ var l = class extends n {
|
|
|
15
15
|
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
16
16
|
}
|
|
17
17
|
setOptions(e) {
|
|
18
|
-
let
|
|
19
|
-
this.options = this.#e.defaultMutationOptions(e),
|
|
18
|
+
let t = this.options;
|
|
19
|
+
this.options = this.#e.defaultMutationOptions(e), a(this.options, t) || this.#e.getMutationCache().notify({
|
|
20
20
|
type: "observerOptionsUpdated",
|
|
21
21
|
mutation: this.#n,
|
|
22
22
|
observer: this
|
|
23
|
-
}),
|
|
23
|
+
}), t?.mutationKey && this.options.mutationKey && n(t.mutationKey) !== n(this.options.mutationKey) ? this.reset() : this.#n?.state.status === "pending" && this.#n.setOptions(this.options);
|
|
24
24
|
}
|
|
25
25
|
onSubscribe() {
|
|
26
26
|
this.listeners.size === 1 && this.#n && (this.#n.addObserver(this), this.#i());
|
|
@@ -41,7 +41,7 @@ var l = class extends n {
|
|
|
41
41
|
return this.#r = t, this.#n?.removeObserver(this), this.#n = this.#e.getMutationCache().build(this.#e, this.options), this.#n.addObserver(this), this.#n.execute(e);
|
|
42
42
|
}
|
|
43
43
|
#i() {
|
|
44
|
-
let e = this.#n?.state ??
|
|
44
|
+
let e = this.#n?.state ?? t();
|
|
45
45
|
this.#t = {
|
|
46
46
|
...e,
|
|
47
47
|
isPending: e.status === "pending",
|
|
@@ -53,7 +53,7 @@ var l = class extends n {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
#a(e) {
|
|
56
|
-
|
|
56
|
+
i.batch(() => {
|
|
57
57
|
let t = this.#r;
|
|
58
58
|
if (t && this.hasListeners()) {
|
|
59
59
|
let n = this.#t.variables, r = this.#t.context, i = {
|
|
@@ -91,16 +91,16 @@ var l = class extends n {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
// ../../node_modules/.pnpm/@tanstack+react-query@5.
|
|
94
|
+
// ../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useMutation.js
|
|
95
95
|
function u(t, n) {
|
|
96
|
-
let
|
|
96
|
+
let a = e(n), [o] = c.useState(() => new l(a, t));
|
|
97
97
|
c.useEffect(() => {
|
|
98
|
-
|
|
99
|
-
}, [
|
|
100
|
-
let u = c.useSyncExternalStore(c.useCallback((e) =>
|
|
101
|
-
|
|
102
|
-
}, [
|
|
103
|
-
if (u.error && o
|
|
98
|
+
o.setOptions(t);
|
|
99
|
+
}, [o, t]);
|
|
100
|
+
let u = c.useSyncExternalStore(c.useCallback((e) => o.subscribe(i.batchCalls(e)), [o]), () => o.getCurrentResult(), () => o.getCurrentResult()), d = c.useCallback((...e) => {
|
|
101
|
+
o.mutate(e[0], e[1]).catch(r);
|
|
102
|
+
}, [o]);
|
|
103
|
+
if (u.error && s(o.options.throwOnError, [u.error])) throw u.error;
|
|
104
104
|
return {
|
|
105
105
|
...u,
|
|
106
106
|
mutate: d,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.js","names":["React","useQueryClient","shallowEqualObjects","Subscribable","hashKey","noop","notifyManager","shouldThrowError","getDefaultState","React$1","MutationObserver","#client","client","options","#updateResult","prevOptions","#currentMutation","#notify","action","#currentResult","#mutateOptions","variables","state","mutateOptions","onMutateResult","context","useMutation","queryClient","observer","result","onStoreChange","mutate","args"],"sources":["../../../../node_modules/.pnpm/@tanstack+query-core@5.107.1/node_modules/@tanstack/query-core/build/modern/mutationObserver.js","../../../../node_modules/.pnpm/@tanstack+react-query@5.107.1_@types+react@19.3.0_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useMutation.js"],"sourcesContent":["import { hashKey, shallowEqualObjects } from \"./utils.js\";\nimport { Subscribable } from \"./subscribable.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { getDefaultState } from \"./mutation.js\";\n// src/mutationObserver.ts\n/**\n* Observes a single mutation and derives a `MutationObserverResult` from it.\n* A framework hook like `useMutation` creates one `MutationObserver` per hook\n* call, keeps it stable across re-renders, calls `setOptions` when the options\n* passed to the hook change, subscribes to it to re-render on updates, and\n* reads `getCurrentResult()` for the value to return. Calling `mutate()`\n* builds a new underlying `Mutation` in the `MutationCache` and executes it.\n* @example\n* ```ts\n* const observer = new MutationObserver(queryClient, {\n* mutationFn: (variables: { title: string }) => addPost(variables),\n* })\n* ```\n*/\nvar MutationObserver = class extends Subscribable {\n\t#client;\n\t#currentResult = void 0;\n\t#currentMutation;\n\t#mutateOptions;\n\tconstructor(client, options) {\n\t\tsuper();\n\t\tthis.#client = client;\n\t\tthis.setOptions(options);\n\t\tthis.bindMethods();\n\t\tthis.#updateResult();\n\t}\n\t/**\n\t* Binds the methods of the result (`mutate` and `reset`) to the observer, so they keep working when\n\t* destructured from it.\n\t*/\n\tbindMethods() {\n\t\tthis.mutate = this.mutate.bind(this);\n\t\tthis.reset = this.reset.bind(this);\n\t}\n\t/**\n\t* Updates the observer's options.\n\t*\n\t* If the new `mutationKey` differs from the previous one (and both were\n\t* defined), the observer is reset, detaching it from the mutation it was\n\t* observing. Otherwise, if the currently observed mutation is still\n\t* `pending`, its options are updated in place as well.\n\t* @param options - The new mutation observer options. They are defaulted with {@link\n\t* QueryClient#defaultMutationOptions} before being applied.\n\t* @example\n\t* ```ts\n\t* observer.setOptions({\n\t* mutationFn: (variables: { title: string }) => addPost(variables),\n\t* onSuccess: (data) => console.log(data),\n\t* })\n\t* ```\n\t*/\n\tsetOptions(options) {\n\t\tconst prevOptions = this.options;\n\t\tthis.options = this.#client.defaultMutationOptions(options);\n\t\tif (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({\n\t\t\ttype: \"observerOptionsUpdated\",\n\t\t\tmutation: this.#currentMutation,\n\t\t\tobserver: this\n\t\t});\n\t\tif (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();\n\t\telse if (this.#currentMutation?.state.status === \"pending\") this.#currentMutation.setOptions(this.options);\n\t}\n\tonSubscribe() {\n\t\tif (this.listeners.size === 1 && this.#currentMutation) {\n\t\t\tthis.#currentMutation.addObserver(this);\n\t\t\tthis.#updateResult();\n\t\t}\n\t}\n\tonUnsubscribe() {\n\t\tif (!this.hasListeners()) this.#currentMutation?.removeObserver(this);\n\t}\n\t/**\n\t* Updates the observer's result when the observed mutation changes, and notifies its listeners.\n\t* @internal\n\t* @param action - The action that updated the observed mutation, passed on to the observer's\n\t* callbacks.\n\t*/\n\tonMutationUpdate(action) {\n\t\tthis.#updateResult();\n\t\tthis.#notify(action);\n\t}\n\t/**\n\t* Returns the observer's current result, derived from the observed\n\t* mutation's state (or the default, `idle` state if no mutation has been\n\t* built yet, e.g. before the first `mutate()` call or after `reset()`).\n\t* @returns The observer's latest result.\n\t*/\n\tgetCurrentResult() {\n\t\treturn this.#currentResult;\n\t}\n\t/**\n\t* Detaches the observer from the mutation it is currently observing (if\n\t* any) and resets the observed result back to its default, `idle` state.\n\t*\n\t* This does not cancel an in-flight mutation; the mutation itself keeps\n\t* running to completion and its own callbacks still fire, but this\n\t* observer stops reflecting its state and a subsequent `mutate()` call\n\t* will build a brand new mutation.\n\t* @see {@link MutationObserver#mutate}\n\t* @example\n\t* ```ts\n\t* observer.reset()\n\t* ```\n\t*/\n\treset() {\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = void 0;\n\t\tthis.#updateResult();\n\t\tthis.#notify();\n\t}\n\t/**\n\t* Builds a new `Mutation` in the `MutationCache` using the observer's\n\t* current options, detaches this observer from any previously observed\n\t* mutation, attaches it to the new one, and executes it with the given\n\t* variables.\n\t*\n\t* The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are\n\t* invoked once the mutation settles, in addition to any callbacks defined\n\t* on the observer's own options.\n\t* @param variables - The variables passed to the `mutationFn`.\n\t* @param options - Per-call `onSuccess`, `onError`, and `onSettled` callbacks.\n\t* @returns A promise that resolves with the mutation's data, or rejects with its error.\n\t* @example\n\t* ```ts\n\t* await observer.mutate(\n\t* { title: 'New post' },\n\t* { onSuccess: (data) => console.log(data) },\n\t* )\n\t* ```\n\t*/\n\tmutate(variables, options) {\n\t\tthis.#mutateOptions = options;\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);\n\t\tthis.#currentMutation.addObserver(this);\n\t\treturn this.#currentMutation.execute(variables);\n\t}\n\t#updateResult() {\n\t\tconst state = this.#currentMutation?.state ?? getDefaultState();\n\t\tthis.#currentResult = {\n\t\t\t...state,\n\t\t\tisPending: state.status === \"pending\",\n\t\t\tisSuccess: state.status === \"success\",\n\t\t\tisError: state.status === \"error\",\n\t\t\tisIdle: state.status === \"idle\",\n\t\t\tmutate: this.mutate,\n\t\t\treset: this.reset\n\t\t};\n\t}\n\t#notify(action) {\n\t\tnotifyManager.batch(() => {\n\t\t\tconst mutateOptions = this.#mutateOptions;\n\t\t\tif (mutateOptions && this.hasListeners()) {\n\t\t\t\tconst variables = this.#currentResult.variables;\n\t\t\t\tconst onMutateResult = this.#currentResult.context;\n\t\t\t\tconst context = {\n\t\t\t\t\tclient: this.#client,\n\t\t\t\t\tmeta: this.options.meta,\n\t\t\t\t\tmutationKey: this.options.mutationKey\n\t\t\t\t};\n\t\t\t\tif (action?.type === \"success\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t} else if (action?.type === \"error\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onError?.(action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.listeners.forEach((listener) => {\n\t\t\t\tlistener(this.#currentResult);\n\t\t\t});\n\t\t});\n\t}\n};\nexport { MutationObserver };\n\n//# sourceMappingURL=mutationObserver.js.map","\"use client\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport * as React from \"react\";\nimport { MutationObserver, noop, notifyManager, shouldThrowError } from \"@tanstack/query-core\";\n// src/useMutation.ts\n/**\n* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n* `useMutation` is the hook for that.\n* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.\n* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n* be used.\n* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n* fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n* the mutation settles removes the subscription and prevents them from firing.\n* @throws {Error} The mutation error, when `throwOnError` is `true` or returns `true` for it, so that it is\n* thrown to the nearest error boundary.\n* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look\n* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).\n* @example\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <button\n* onClick={() =>\n* addMutation.mutate('Item', {\n* onError: (error) => console.error('Failed to add item:', error),\n* })\n* }\n* >\n* Add\n* </button>\n* )\n* }\n* ```\n* @example\n* Rendering the mutation's own state, rather than just firing it off:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <div>\n* {addMutation.isPending ? (\n* 'Adding todo...'\n* ) : (\n* <>\n* {addMutation.isError ? (\n* <div>An error occurred: {addMutation.error.message}</div>\n* ) : null}\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* </>\n* )}\n* </div>\n* )\n* }\n* ```\n* @example\n* Optimistic update via `onMutate`, rolling back on `onError`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onMutate: async (newTodo) => {\n* await queryClient.cancelQueries({ queryKey: ['todos'] })\n* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n*\n* queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n* ...(old ?? []),\n* newTodo,\n* ])\n*\n* // Passed to `onError` as `onMutateResult` if the mutation fails.\n* return { previousTodos }\n* },\n* onError: (_err, _newTodo, onMutateResult) => {\n* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n* },\n* onSettled: () => {\n* queryClient.invalidateQueries({ queryKey: ['todos'] })\n* },\n* })\n*\n* return (\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* )\n* }\n* ```\n* @example\n* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n* promise per call instead, so you can wait for all of them when they succeed:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* try {\n* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n* } catch (error) {\n* console.error('Failed to add todos:', error)\n* }\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n* @example\n* If some of the mutations above can fail independently of the others, and you want to know which ones\n* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n* `Promise.allSettled`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* const addResults = await Promise.allSettled(\n* todos.map((todo) => addMutation.mutateAsync(todo)),\n* )\n*\n* addResults.forEach((addResult, index) => {\n* if (addResult.status === 'rejected') {\n* console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n* }\n* })\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n*/\nfunction useMutation(options, queryClient) {\n\tconst client = useQueryClient(queryClient);\n\tconst [observer] = React.useState(() => new MutationObserver(client, options));\n\tReact.useEffect(() => {\n\t\tobserver.setOptions(options);\n\t}, [observer, options]);\n\tconst result = React.useSyncExternalStore(React.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());\n\tconst mutate = React.useCallback((...args) => {\n\t\tobserver.mutate(args[0], args[1]).catch(noop);\n\t}, [observer]);\n\tif (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;\n\treturn {\n\t\t...result,\n\t\tmutate,\n\t\tmutateAsync: result.mutate\n\t};\n}\nexport { useMutation };\n\n//# sourceMappingURL=useMutation.js.map"],"ignoreList":[0,1],"mappings":";;;;;AAmBA,IAAIU,IAAmB,cAAcP,EAAa;CACjD;CACA,KAAiB,KAAK;CACtB;CACA;CACA,YAAY,GAAQ,GAAS;EAK5B,AAJA,MAAM,GACN,KAAKQ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,EAAe0B,CAAW,GACnC,CAACC,KAAY5B,EAAM,eAAe,IAAIU,EAAiBE,GAAQC,CAAO,CAAC;CAC7E,EAAM,gBAAgB;EACrB,EAAS,WAAWA,CAAO;CAC5B,GAAG,CAACe,GAAUf,CAAO,CAAC;CACtB,IAAMgB,IAAS7B,EAAM,qBAAqBA,EAAM,aAAa,MAAkB4B,EAAS,UAAUtB,EAAc,WAAWwB,CAAa,CAAC,GAAG,CAACF,CAAQ,CAAC,SAASA,EAAS,iBAAiB,SAASA,EAAS,iBAAiB,CAAC,GACvNG,IAAS/B,EAAM,aAAa,GAAGgC,MAAS;EAC7C,EAAS,OAAOA,EAAK,IAAIA,EAAK,EAAE,CAAC,CAAC,MAAM3B,CAAI;CAC7C,GAAG,CAACuB,CAAQ,CAAC;CACb,IAAIC,EAAO,SAAStB,EAAiBqB,EAAS,QAAQ,cAAc,CAACC,EAAO,KAAK,CAAC,GAAG,MAAMA,EAAO;CAClG,OAAO;EACN,GAAGA;EACH;EACA,aAAaA,EAAO;CACrB;AACD"}
|
|
1
|
+
{"version":3,"file":"useMutation.js","names":["React","useQueryClient","getDefaultState","hashKey","noop","notifyManager","shallowEqualObjects","Subscribable","shouldThrowError","React$1","MutationObserver","#client","client","options","#updateResult","prevOptions","#currentMutation","#notify","action","#currentResult","#mutateOptions","variables","state","mutateOptions","onMutateResult","context","useMutation","queryClient","observer","result","onStoreChange","mutate","args"],"sources":["../../../../node_modules/.pnpm/@tanstack+query-core@5.108.4/node_modules/@tanstack/query-core/build/modern/mutationObserver.js","../../../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useMutation.js"],"sourcesContent":["import { getDefaultState } from \"./mutation.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { Subscribable } from \"./subscribable.js\";\nimport { hashKey, shallowEqualObjects } from \"./utils.js\";\n// src/mutationObserver.ts\n/**\n* Observes a single mutation and derives a `MutationObserverResult` from it.\n* A framework hook like `useMutation` creates one `MutationObserver` per hook\n* call, keeps it stable across re-renders, calls `setOptions` when the options\n* passed to the hook change, subscribes to it to re-render on updates, and\n* reads `getCurrentResult()` for the value to return. Calling `mutate()`\n* builds a new underlying `Mutation` in the `MutationCache` and executes it.\n* @example\n* ```ts\n* const observer = new MutationObserver(queryClient, {\n* mutationFn: (variables: { title: string }) => addPost(variables),\n* })\n* ```\n*/\nvar MutationObserver = class extends Subscribable {\n\t#client;\n\t#currentResult = void 0;\n\t#currentMutation;\n\t#mutateOptions;\n\tconstructor(client, options) {\n\t\tsuper();\n\t\tthis.#client = client;\n\t\tthis.setOptions(options);\n\t\tthis.bindMethods();\n\t\tthis.#updateResult();\n\t}\n\t/**\n\t* Binds the methods of the result (`mutate` and `reset`) to the observer, so they keep working when\n\t* destructured from it.\n\t*/\n\tbindMethods() {\n\t\tthis.mutate = this.mutate.bind(this);\n\t\tthis.reset = this.reset.bind(this);\n\t}\n\t/**\n\t* Updates the observer's options.\n\t*\n\t* If the new `mutationKey` differs from the previous one (and both were\n\t* defined), the observer is reset, detaching it from the mutation it was\n\t* observing. Otherwise, if the currently observed mutation is still\n\t* `pending`, its options are updated in place as well.\n\t* @param options - The new mutation observer options. They are defaulted with {@link\n\t* QueryClient#defaultMutationOptions} before being applied.\n\t* @example\n\t* ```ts\n\t* observer.setOptions({\n\t* mutationFn: (variables: { title: string }) => addPost(variables),\n\t* onSuccess: (data) => console.log(data),\n\t* })\n\t* ```\n\t*/\n\tsetOptions(options) {\n\t\tconst prevOptions = this.options;\n\t\tthis.options = this.#client.defaultMutationOptions(options);\n\t\tif (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({\n\t\t\ttype: \"observerOptionsUpdated\",\n\t\t\tmutation: this.#currentMutation,\n\t\t\tobserver: this\n\t\t});\n\t\tif (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();\n\t\telse if (this.#currentMutation?.state.status === \"pending\") this.#currentMutation.setOptions(this.options);\n\t}\n\tonSubscribe() {\n\t\tif (this.listeners.size === 1 && this.#currentMutation) {\n\t\t\tthis.#currentMutation.addObserver(this);\n\t\t\tthis.#updateResult();\n\t\t}\n\t}\n\tonUnsubscribe() {\n\t\tif (!this.hasListeners()) this.#currentMutation?.removeObserver(this);\n\t}\n\t/**\n\t* Updates the observer's result when the observed mutation changes, and notifies its listeners.\n\t* @internal\n\t* @param action - The action that updated the observed mutation, passed on to the observer's\n\t* callbacks.\n\t*/\n\tonMutationUpdate(action) {\n\t\tthis.#updateResult();\n\t\tthis.#notify(action);\n\t}\n\t/**\n\t* Returns the observer's current result, derived from the observed\n\t* mutation's state (or the default, `idle` state if no mutation has been\n\t* built yet, e.g. before the first `mutate()` call or after `reset()`).\n\t* @returns The observer's latest result.\n\t*/\n\tgetCurrentResult() {\n\t\treturn this.#currentResult;\n\t}\n\t/**\n\t* Detaches the observer from the mutation it is currently observing (if\n\t* any) and resets the observed result back to its default, `idle` state.\n\t*\n\t* This does not cancel an in-flight mutation; the mutation itself keeps\n\t* running to completion and its own callbacks still fire, but this\n\t* observer stops reflecting its state and a subsequent `mutate()` call\n\t* will build a brand new mutation.\n\t* @see {@link MutationObserver#mutate}\n\t* @example\n\t* ```ts\n\t* observer.reset()\n\t* ```\n\t*/\n\treset() {\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = void 0;\n\t\tthis.#updateResult();\n\t\tthis.#notify();\n\t}\n\t/**\n\t* Builds a new `Mutation` in the `MutationCache` using the observer's\n\t* current options, detaches this observer from any previously observed\n\t* mutation, attaches it to the new one, and executes it with the given\n\t* variables.\n\t*\n\t* The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are\n\t* invoked once the mutation settles, in addition to any callbacks defined\n\t* on the observer's own options.\n\t* @param variables - The variables passed to the `mutationFn`.\n\t* @param options - Per-call `onSuccess`, `onError`, and `onSettled` callbacks.\n\t* @returns A promise that resolves with the mutation's data, or rejects with its error.\n\t* @example\n\t* ```ts\n\t* await observer.mutate(\n\t* { title: 'New post' },\n\t* { onSuccess: (data) => console.log(data) },\n\t* )\n\t* ```\n\t*/\n\tmutate(variables, options) {\n\t\tthis.#mutateOptions = options;\n\t\tthis.#currentMutation?.removeObserver(this);\n\t\tthis.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);\n\t\tthis.#currentMutation.addObserver(this);\n\t\treturn this.#currentMutation.execute(variables);\n\t}\n\t#updateResult() {\n\t\tconst state = this.#currentMutation?.state ?? getDefaultState();\n\t\tthis.#currentResult = {\n\t\t\t...state,\n\t\t\tisPending: state.status === \"pending\",\n\t\t\tisSuccess: state.status === \"success\",\n\t\t\tisError: state.status === \"error\",\n\t\t\tisIdle: state.status === \"idle\",\n\t\t\tmutate: this.mutate,\n\t\t\treset: this.reset\n\t\t};\n\t}\n\t#notify(action) {\n\t\tnotifyManager.batch(() => {\n\t\t\tconst mutateOptions = this.#mutateOptions;\n\t\t\tif (mutateOptions && this.hasListeners()) {\n\t\t\t\tconst variables = this.#currentResult.variables;\n\t\t\t\tconst onMutateResult = this.#currentResult.context;\n\t\t\t\tconst context = {\n\t\t\t\t\tclient: this.#client,\n\t\t\t\t\tmeta: this.options.meta,\n\t\t\t\t\tmutationKey: this.options.mutationKey\n\t\t\t\t};\n\t\t\t\tif (action?.type === \"success\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t} else if (action?.type === \"error\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onError?.(action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tPromise.reject(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.listeners.forEach((listener) => {\n\t\t\t\tlistener(this.#currentResult);\n\t\t\t});\n\t\t});\n\t}\n};\nexport { MutationObserver };\n\n//# sourceMappingURL=mutationObserver.js.map","\"use client\";\nimport { useQueryClient } from \"./QueryClientProvider.js\";\nimport { MutationObserver, noop, notifyManager, shouldThrowError } from \"@tanstack/query-core\";\nimport * as React from \"react\";\n// src/useMutation.ts\n/**\n* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n* `useMutation` is the hook for that.\n* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.\n* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n* be used.\n* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call callbacks\n* fire only for the latest call you've made, and only while the component is still mounted — unmounting before\n* the mutation settles removes the subscription and prevents them from firing.\n* @throws {Error} The mutation error, when `throwOnError` is `true` or returns `true` for it, so that it is\n* thrown to the nearest error boundary.\n* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look\n* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).\n* @example\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <button\n* onClick={() =>\n* addMutation.mutate('Item', {\n* onError: (error) => console.error('Failed to add item:', error),\n* })\n* }\n* >\n* Add\n* </button>\n* )\n* }\n* ```\n* @example\n* Rendering the mutation's own state, rather than just firing it off:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* return (\n* <div>\n* {addMutation.isPending ? (\n* 'Adding todo...'\n* ) : (\n* <>\n* {addMutation.isError ? (\n* <div>An error occurred: {addMutation.error.message}</div>\n* ) : null}\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* </>\n* )}\n* </div>\n* )\n* }\n* ```\n* @example\n* Optimistic update via `onMutate`, rolling back on `onError`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodo() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onMutate: async (newTodo) => {\n* await queryClient.cancelQueries({ queryKey: ['todos'] })\n* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n*\n* queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n* ...(old ?? []),\n* newTodo,\n* ])\n*\n* // Passed to `onError` as `onMutateResult` if the mutation fails.\n* return { previousTodos }\n* },\n* onError: (_err, _newTodo, onMutateResult) => {\n* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n* },\n* onSettled: () => {\n* queryClient.invalidateQueries({ queryKey: ['todos'] })\n* },\n* })\n*\n* return (\n* <button onClick={() => addMutation.mutate('Item')}>Add</button>\n* )\n* }\n* ```\n* @example\n* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n* promise per call instead, so you can wait for all of them when they succeed:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* try {\n* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n* } catch (error) {\n* console.error('Failed to add todos:', error)\n* }\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n* @example\n* If some of the mutations above can fail independently of the others, and you want to know which ones\n* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n* `Promise.allSettled`:\n* ```tsx\n* import { useMutation, useQueryClient } from '@tanstack/react-query'\n*\n* function AddTodos() {\n* const queryClient = useQueryClient()\n*\n* const addMutation = useMutation({\n* mutationFn: addTodo,\n* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n* })\n*\n* async function handleAddAll(todos: Array<string>) {\n* const addResults = await Promise.allSettled(\n* todos.map((todo) => addMutation.mutateAsync(todo)),\n* )\n*\n* addResults.forEach((addResult, index) => {\n* if (addResult.status === 'rejected') {\n* console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n* }\n* })\n* }\n*\n* return (\n* <button onClick={() => handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])}>\n* Add all\n* </button>\n* )\n* }\n* ```\n*/\nfunction useMutation(options, queryClient) {\n\tconst client = useQueryClient(queryClient);\n\tconst [observer] = React.useState(() => new MutationObserver(client, options));\n\tReact.useEffect(() => {\n\t\tobserver.setOptions(options);\n\t}, [observer, options]);\n\tconst result = React.useSyncExternalStore(React.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());\n\tconst mutate = React.useCallback((...args) => {\n\t\tobserver.mutate(args[0], args[1]).catch(noop);\n\t}, [observer]);\n\tif (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;\n\treturn {\n\t\t...result,\n\t\t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EAAO,OAAOG,GAAWG,GAAgBC,CAAO;KACnF,SAAS,GAAG;MACX,QAAQ,OAAO,CAAC;KACjB;IACD;GACD;GACA,KAAK,UAAU,SAAS,MAAa;IACpC,EAAS,KAAKN,EAAc;GAC7B,CAAC;EACF,CAAC;CACF;AACD;;ACrBA,SAASO,EAAY,GAAS,GAAa;CAC1C,IAAMd,IAASX,EAAe0B,CAAW,GACnC,CAACC,KAAY5B,EAAM,eAAe,IAAIU,EAAiBE,GAAQC,CAAO,CAAC;CAC7E,EAAM,gBAAgB;EACrB,EAAS,WAAWA,CAAO;CAC5B,GAAG,CAACe,GAAUf,CAAO,CAAC;CACtB,IAAMgB,IAAS7B,EAAM,qBAAqBA,EAAM,aAAa,MAAkB4B,EAAS,UAAUvB,EAAc,WAAWyB,CAAa,CAAC,GAAG,CAACF,CAAQ,CAAC,SAASA,EAAS,iBAAiB,SAASA,EAAS,iBAAiB,CAAC,GACvNG,IAAS/B,EAAM,aAAa,GAAGgC,MAAS;EAC7C,EAAS,OAAOA,EAAK,IAAIA,EAAK,EAAE,CAAC,CAAC,MAAM5B,CAAI;CAC7C,GAAG,CAACwB,CAAQ,CAAC;CACb,IAAIC,EAAO,SAASrB,EAAiBoB,EAAS,QAAQ,cAAc,CAACC,EAAO,KAAK,CAAC,GAAG,MAAMA,EAAO;CAClG,OAAO;EACN,GAAGA;EACH;EACA,aAAaA,EAAO;CACrB;AACD"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { n as e } from "./QueryClientProvider.js";
|
|
2
|
-
import { C as t,
|
|
2
|
+
import { C as t, S as n, _ as r, d as i, g as a, m as o, n as s, o as c, s as l, v as u, w as d, x as f, y as p } from "./query.js";
|
|
3
3
|
import * as m from "react";
|
|
4
4
|
import { useMemo as h } from "react";
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
|
-
// ../../node_modules/.pnpm/@tanstack+query
|
|
7
|
-
var g =
|
|
6
|
+
// ../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
7
|
+
var g = m.createContext(!1), _ = () => m.useContext(g);
|
|
8
|
+
g.Provider;
|
|
9
|
+
// ../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
10
|
+
function v() {
|
|
11
|
+
let e = !1;
|
|
12
|
+
return {
|
|
13
|
+
clearReset: () => {
|
|
14
|
+
e = !1;
|
|
15
|
+
},
|
|
16
|
+
reset: () => {
|
|
17
|
+
e = !0;
|
|
18
|
+
},
|
|
19
|
+
isReset: () => e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var y = m.createContext(v()), b = () => m.useContext(y), x = class extends d {
|
|
8
23
|
#e;
|
|
9
24
|
#t = void 0;
|
|
10
25
|
#n = void 0;
|
|
@@ -20,42 +35,42 @@ var g = class extends r {
|
|
|
20
35
|
#f;
|
|
21
36
|
#p = /* @__PURE__ */ new Set();
|
|
22
37
|
constructor(e, t) {
|
|
23
|
-
super(), this.options = t, this.#e = e, this.#
|
|
38
|
+
super(), this.options = t, this.#e = e, this.#a = null, this.bindMethods(), this.setOptions(t);
|
|
24
39
|
}
|
|
25
40
|
bindMethods() {
|
|
26
41
|
this.refetch = this.refetch.bind(this);
|
|
27
42
|
}
|
|
28
43
|
onSubscribe() {
|
|
29
|
-
this.listeners.size === 1 && (this.#t.addObserver(this),
|
|
44
|
+
this.listeners.size === 1 && (this.#t.addObserver(this), C(this.#t, this.options) ? this.#m() : this.updateResult(), this.#y());
|
|
30
45
|
}
|
|
31
46
|
onUnsubscribe() {
|
|
32
47
|
this.hasListeners() || this.destroy();
|
|
33
48
|
}
|
|
34
49
|
shouldFetchOnReconnect() {
|
|
35
|
-
return
|
|
50
|
+
return w(this.#t, this.options, this.options.refetchOnReconnect);
|
|
36
51
|
}
|
|
37
52
|
shouldFetchOnWindowFocus() {
|
|
38
|
-
return
|
|
53
|
+
return w(this.#t, this.options, this.options.refetchOnWindowFocus);
|
|
39
54
|
}
|
|
40
55
|
destroy() {
|
|
41
56
|
this.listeners = /* @__PURE__ */ new Set(), this.#b(), this.#x(), this.#t.removeObserver(this);
|
|
42
57
|
}
|
|
43
58
|
setOptions(e) {
|
|
44
|
-
let t = this.options,
|
|
45
|
-
if (this.options = this.#e.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof
|
|
46
|
-
this.#S(), this.#t.setOptions(this.options), t._defaulted && !
|
|
59
|
+
let t = this.options, n = this.#t;
|
|
60
|
+
if (this.options = this.#e.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof r(this.options.enabled, this.#t) != "boolean") throw Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
61
|
+
this.#S(), this.#t.setOptions(this.options), t._defaulted && !u(this.options, t) && this.#e.getQueryCache().notify({
|
|
47
62
|
type: "observerOptionsUpdated",
|
|
48
63
|
query: this.#t,
|
|
49
64
|
observer: this
|
|
50
65
|
});
|
|
51
66
|
let i = this.hasListeners();
|
|
52
|
-
i &&
|
|
67
|
+
i && T(this.#t, n, this.options, t) && this.#m(), this.updateResult(), i && (this.#t !== n || r(this.options.enabled, this.#t) !== r(t.enabled, this.#t) || r(this.options.staleTime, this.#t) !== r(t.staleTime, this.#t)) && this.#g();
|
|
53
68
|
let a = this.#_();
|
|
54
|
-
i && (this.#t !==
|
|
69
|
+
i && (this.#t !== n || r(this.options.enabled, this.#t) !== r(t.enabled, this.#t) || a !== this.#f) && this.#v(a);
|
|
55
70
|
}
|
|
56
71
|
getOptimisticResult(e) {
|
|
57
|
-
let t = this.#e.getQueryCache().build(this.#e, e),
|
|
58
|
-
return
|
|
72
|
+
let t = this.#e.getQueryCache().build(this.#e, e), n = this.createResult(t, e);
|
|
73
|
+
return u(this.getCurrentResult(), n) || (this.#r = n, this.#i = e), n;
|
|
59
74
|
}
|
|
60
75
|
getCurrentResult() {
|
|
61
76
|
return this.#r;
|
|
@@ -94,104 +109,104 @@ var g = class extends r {
|
|
|
94
109
|
#m(e) {
|
|
95
110
|
this.#S();
|
|
96
111
|
let t = this.#t.fetch(this.options, e);
|
|
97
|
-
return e?.throwOnError || (t = t.catch(
|
|
112
|
+
return e?.throwOnError || (t = t.catch(o)), t;
|
|
98
113
|
}
|
|
99
114
|
#h(e) {
|
|
100
|
-
return !
|
|
115
|
+
return !l() && r(this.options.enabled, this.#t) !== !1 && i(e);
|
|
101
116
|
}
|
|
102
117
|
#g() {
|
|
103
118
|
this.#b();
|
|
104
|
-
let e =
|
|
119
|
+
let e = r(this.options.staleTime, this.#t);
|
|
105
120
|
if (this.#r.isStale || !this.#h(e)) return;
|
|
106
|
-
let
|
|
107
|
-
this.#u =
|
|
121
|
+
let t = f(this.#r.dataUpdatedAt, e) + 1;
|
|
122
|
+
this.#u = n.setTimeout(() => {
|
|
108
123
|
this.#r.isStale || this.updateResult();
|
|
109
|
-
},
|
|
124
|
+
}, t);
|
|
110
125
|
}
|
|
111
126
|
#_() {
|
|
112
|
-
return
|
|
127
|
+
return r(this.options.refetchInterval, this.#t) ?? !1;
|
|
113
128
|
}
|
|
114
129
|
#v(e) {
|
|
115
|
-
this.#x(), this.#f = e, this.#f !== 0 && this.#h(this.#f) && (this.#d =
|
|
116
|
-
(this.options.refetchIntervalInBackground ||
|
|
130
|
+
this.#x(), this.#f = e, this.#f !== 0 && this.#h(this.#f) && (this.#d = n.setInterval(() => {
|
|
131
|
+
(this.options.refetchIntervalInBackground || t.isFocused()) && this.#m();
|
|
117
132
|
}, this.#f));
|
|
118
133
|
}
|
|
119
134
|
#y() {
|
|
120
135
|
this.#g(), this.#v(this.#_());
|
|
121
136
|
}
|
|
122
137
|
#b() {
|
|
123
|
-
this.#u !== void 0 && (
|
|
138
|
+
this.#u !== void 0 && (n.clearTimeout(this.#u), this.#u = void 0);
|
|
124
139
|
}
|
|
125
140
|
#x() {
|
|
126
|
-
this.#d !== void 0 && (
|
|
141
|
+
this.#d !== void 0 && (n.clearInterval(this.#d), this.#d = void 0);
|
|
127
142
|
}
|
|
128
143
|
createResult(e, t) {
|
|
129
|
-
let n = this.#t,
|
|
144
|
+
let n = this.#t, i = this.options, o = this.#r, c = this.#i, l = e === n ? this.#n : e.state, { state: u } = e, d = { ...u }, f = !1, p;
|
|
130
145
|
if (t._optimisticResults) {
|
|
131
|
-
let
|
|
132
|
-
(a ||
|
|
146
|
+
let r = this.hasListeners(), a = !r && C(e, t), o = r && T(e, n, t, i);
|
|
147
|
+
(a || o) && (d = {
|
|
133
148
|
...d,
|
|
134
|
-
...
|
|
149
|
+
...s(u.data, e.options)
|
|
135
150
|
}), t._optimisticResults === "isRestoring" && (d.fetchStatus = "idle");
|
|
136
151
|
}
|
|
137
|
-
let { error:
|
|
138
|
-
|
|
139
|
-
let
|
|
140
|
-
if (t.placeholderData !== void 0 &&
|
|
141
|
-
let e;
|
|
142
|
-
|
|
152
|
+
let { error: m, errorUpdatedAt: h, status: g } = d;
|
|
153
|
+
p = d.data;
|
|
154
|
+
let _ = !1;
|
|
155
|
+
if (t.placeholderData !== void 0 && p === void 0 && g === "pending") {
|
|
156
|
+
let e, n = o?.isPlaceholderData && t.placeholderData === c?.placeholderData;
|
|
157
|
+
n ? (e = o.data, _ = !0) : e = typeof t.placeholderData == "function" ? t.placeholderData(this.#l?.state.data, this.#l) : t.placeholderData, (n || e !== void 0) && (g = "success", p = a(t.select && !_ ? this.#s : o?.data, e, t), f = !0);
|
|
143
158
|
}
|
|
144
|
-
if (t.select &&
|
|
145
|
-
if (
|
|
159
|
+
if (t.select && p !== void 0 && !_) {
|
|
160
|
+
if (p === this.#s && t.select === this.#o) p = this.#c;
|
|
146
161
|
else try {
|
|
147
|
-
this.#
|
|
162
|
+
this.#o = t.select, this.#s = p, p = t.select(p), p = a(o?.data, p, t), this.#c = p, this.#a = null;
|
|
148
163
|
} catch (e) {
|
|
149
|
-
this.#
|
|
164
|
+
this.#a = e;
|
|
150
165
|
}
|
|
151
|
-
} else
|
|
152
|
-
this.#
|
|
153
|
-
let
|
|
166
|
+
} else p === void 0 && (this.#s = void 0, this.#a = null);
|
|
167
|
+
this.#a && (m = this.#a, p = this.#c, h = o?.error === m ? o.errorUpdatedAt : Date.now(), g = "error", f = !1);
|
|
168
|
+
let v = d.fetchStatus === "fetching", y = g === "pending", b = g === "error", x = y && v, S = p !== void 0;
|
|
154
169
|
return {
|
|
155
|
-
status:
|
|
170
|
+
status: g,
|
|
156
171
|
fetchStatus: d.fetchStatus,
|
|
157
|
-
isPending:
|
|
158
|
-
isSuccess:
|
|
159
|
-
isError:
|
|
160
|
-
isInitialLoading:
|
|
161
|
-
isLoading:
|
|
162
|
-
data:
|
|
172
|
+
isPending: y,
|
|
173
|
+
isSuccess: g === "success",
|
|
174
|
+
isError: b,
|
|
175
|
+
isInitialLoading: x,
|
|
176
|
+
isLoading: x,
|
|
177
|
+
data: p,
|
|
163
178
|
dataUpdatedAt: d.dataUpdatedAt,
|
|
164
|
-
error:
|
|
165
|
-
errorUpdatedAt:
|
|
179
|
+
error: m,
|
|
180
|
+
errorUpdatedAt: h,
|
|
166
181
|
failureCount: d.fetchFailureCount,
|
|
167
182
|
failureReason: d.fetchFailureReason,
|
|
168
183
|
errorUpdateCount: d.errorUpdateCount,
|
|
169
184
|
isFetched: e.isFetched(),
|
|
170
|
-
isFetchedAfterMount: d.dataUpdateCount >
|
|
171
|
-
isFetching:
|
|
172
|
-
isRefetching:
|
|
173
|
-
isLoadingError:
|
|
185
|
+
isFetchedAfterMount: d.dataUpdateCount > l.dataUpdateCount || d.errorUpdateCount > l.errorUpdateCount,
|
|
186
|
+
isFetching: v,
|
|
187
|
+
isRefetching: v && !y,
|
|
188
|
+
isLoadingError: b && !S,
|
|
174
189
|
isPaused: d.fetchStatus === "paused",
|
|
175
190
|
isPlaceholderData: f,
|
|
176
|
-
isRefetchError:
|
|
177
|
-
isStale:
|
|
191
|
+
isRefetchError: b && S,
|
|
192
|
+
isStale: E(e, t),
|
|
178
193
|
refetch: this.refetch,
|
|
179
|
-
isEnabled:
|
|
194
|
+
isEnabled: r(t.enabled, e) !== !1
|
|
180
195
|
};
|
|
181
196
|
}
|
|
182
197
|
updateResult() {
|
|
183
198
|
let e = this.#r, t = this.createResult(this.#t, this.options);
|
|
184
|
-
if (this.#i = this
|
|
199
|
+
if (this.#i = this.options, this.#t.state.data !== void 0 && (this.#l = this.#t), u(t, e)) return;
|
|
185
200
|
this.#r = t;
|
|
186
|
-
let
|
|
201
|
+
let n = (() => {
|
|
187
202
|
if (!e) return !0;
|
|
188
203
|
let { notifyOnChangeProps: t } = this.options, n = typeof t == "function" ? t() : t;
|
|
189
204
|
if (n === "all" || !n && !this.#p.size || this.options.throwOnError && this.#r.error !== e.error) return !0;
|
|
190
205
|
for (let t of n ?? this.#p) if (this.#r[t] !== e[t]) return !0;
|
|
191
206
|
return !1;
|
|
192
207
|
})();
|
|
193
|
-
|
|
194
|
-
|
|
208
|
+
c.batch(() => {
|
|
209
|
+
n && this.listeners.forEach((e) => {
|
|
195
210
|
e(this.#r);
|
|
196
211
|
}), this.#e.getQueryCache().notify({
|
|
197
212
|
query: this.#t,
|
|
@@ -209,49 +224,34 @@ var g = class extends r {
|
|
|
209
224
|
this.updateResult(), this.hasListeners() && this.#y();
|
|
210
225
|
}
|
|
211
226
|
};
|
|
212
|
-
function
|
|
213
|
-
return
|
|
227
|
+
function S(e, t) {
|
|
228
|
+
return r(t.enabled, e) !== !1 && e.state.data === void 0 && (e.state.status !== "error" || r(t.retryOnMount, e) !== !1);
|
|
214
229
|
}
|
|
215
|
-
function
|
|
216
|
-
return
|
|
230
|
+
function C(e, t) {
|
|
231
|
+
return S(e, t) || e.state.data !== void 0 && w(e, t, t.refetchOnMount);
|
|
217
232
|
}
|
|
218
|
-
function
|
|
219
|
-
if (
|
|
220
|
-
let
|
|
221
|
-
return
|
|
233
|
+
function w(e, t, n) {
|
|
234
|
+
if (r(t.enabled, e) !== !1 && r(t.staleTime, e) !== "static") {
|
|
235
|
+
let i = r(n, e);
|
|
236
|
+
return i === "always" || i !== !1 && E(e, t);
|
|
222
237
|
}
|
|
223
238
|
return !1;
|
|
224
239
|
}
|
|
225
|
-
function
|
|
226
|
-
return (e !== t ||
|
|
240
|
+
function T(e, t, n, i) {
|
|
241
|
+
return (e !== t || r(i.enabled, e) === !1) && (!n.suspense || e.state.status !== "error") && E(e, n);
|
|
227
242
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
230
|
-
}
|
|
231
|
-
// ../../node_modules/.pnpm/@tanstack+react-query@5.107.1_@types+react@19.3.0_react@19.3.1/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
232
|
-
var S = m.createContext(!1), C = () => m.useContext(S);
|
|
233
|
-
S.Provider;
|
|
234
|
-
// ../../node_modules/.pnpm/@tanstack+react-query@5.107.1_@types+react@19.3.0_react@19.3.1/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
235
|
-
function w() {
|
|
236
|
-
let e = !1;
|
|
237
|
-
return {
|
|
238
|
-
clearReset: () => {
|
|
239
|
-
e = !1;
|
|
240
|
-
},
|
|
241
|
-
reset: () => {
|
|
242
|
-
e = !0;
|
|
243
|
-
},
|
|
244
|
-
isReset: () => e
|
|
245
|
-
};
|
|
243
|
+
function E(e, t) {
|
|
244
|
+
return r(t.enabled, e) !== !1 && e.isStaleByTime(r(t.staleTime, e));
|
|
246
245
|
}
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
// ../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
|
|
247
|
+
var D = (e, t, n) => {
|
|
248
|
+
let r = n?.state.status === "error" && typeof e.throwOnError == "function" ? p(e.throwOnError, [n.state.error, n]) : e.throwOnError;
|
|
249
249
|
(e.suspense || r) && (t.isReset() || (e.retryOnMount = !1));
|
|
250
250
|
}, O = (e) => {
|
|
251
251
|
m.useEffect(() => {
|
|
252
252
|
e.clearReset();
|
|
253
253
|
}, [e]);
|
|
254
|
-
}, k = ({ result: e, errorResetBoundary: t, throwOnError: n, query: r, suspense: i }) => e.isError && !t.isReset() && !e.isFetching && r && (i && e.data === void 0 ||
|
|
254
|
+
}, k = ({ result: e, errorResetBoundary: t, throwOnError: n, query: r, suspense: i }) => e.isError && !t.isReset() && !e.isFetching && r && (i && e.data === void 0 || p(n, [e.error, r])), A = (e) => {
|
|
255
255
|
if (e.suspense) {
|
|
256
256
|
let t = 1e3, n = (e) => e === "static" ? e : Math.max(e ?? t, t), r = e.staleTime;
|
|
257
257
|
e.staleTime = typeof r == "function" ? (...e) => n(r(...e)) : n(r), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, t));
|
|
@@ -259,34 +259,34 @@ var T = m.createContext(w()), E = () => m.useContext(T), D = (e, t, n) => {
|
|
|
259
259
|
}, j = (e, t) => e?.suspense && t.isPending, M = (e, t, n) => t.fetchOptimistic(e).catch(() => {
|
|
260
260
|
n.clearReset();
|
|
261
261
|
});
|
|
262
|
-
// ../../node_modules/.pnpm/@tanstack+react-query@5.
|
|
262
|
+
// ../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
263
263
|
function N(t, n, r) {
|
|
264
264
|
if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t))) throw Error("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");
|
|
265
|
-
let
|
|
265
|
+
let i = _(), a = b(), s = e(r), l = s.defaultQueryOptions(t), u = s.getQueryCache().get(l.queryHash);
|
|
266
266
|
process.env.NODE_ENV !== "production" && (l.queryFn || console.error(`[${l.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`));
|
|
267
267
|
let d = t.subscribed !== !1;
|
|
268
|
-
l._optimisticResults =
|
|
269
|
-
let [f] = m.useState(() => new n(
|
|
268
|
+
l._optimisticResults = i ? "isRestoring" : d ? "optimistic" : void 0, A(l), D(l, a, u), O(a);
|
|
269
|
+
let [f] = m.useState(() => new n(s, l)), p = f.getOptimisticResult(l);
|
|
270
270
|
m.useEffect(() => {
|
|
271
271
|
f.setOptions(l);
|
|
272
272
|
}, [l, f]);
|
|
273
|
-
let h = !
|
|
273
|
+
let h = !i && d;
|
|
274
274
|
if (m.useSyncExternalStore(m.useCallback((e) => {
|
|
275
|
-
let t = h ? f.subscribe(
|
|
275
|
+
let t = h ? f.subscribe(c.batchCalls(e)) : o;
|
|
276
276
|
return f.updateResult(), t;
|
|
277
|
-
}, [f, h]), () => f.getCurrentResult(), () => f.getCurrentResult()), j(l, p)) throw M(l, f,
|
|
277
|
+
}, [f, h]), () => f.getCurrentResult(), () => f.getCurrentResult()), j(l, p)) throw M(l, f, a);
|
|
278
278
|
if (k({
|
|
279
279
|
result: p,
|
|
280
|
-
errorResetBoundary:
|
|
280
|
+
errorResetBoundary: a,
|
|
281
281
|
throwOnError: l.throwOnError,
|
|
282
282
|
query: u,
|
|
283
283
|
suspense: l.suspense
|
|
284
284
|
})) throw p.error;
|
|
285
285
|
return l.notifyOnChangeProps ? p : f.trackResult(p);
|
|
286
286
|
}
|
|
287
|
-
// ../../node_modules/.pnpm/@tanstack+react-query@5.
|
|
287
|
+
// ../../node_modules/.pnpm/@tanstack+react-query@5.108.4_@types+react@19.3.1_react@19.3.1/node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
288
288
|
function P(e, t) {
|
|
289
|
-
return N(e,
|
|
289
|
+
return N(e, x, t);
|
|
290
290
|
}
|
|
291
291
|
// src/hooks/useQueryMemo/useQueryMemo.ts
|
|
292
292
|
var F = (e, t) => {
|