@tanstack/react-query 4.35.7 → 4.39.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/build/lib/__tests__/queryOptions.types.test.d.ts +2 -0
- package/build/lib/__tests__/useSuspenseQueries.types.test.d.ts +6 -0
- package/build/lib/__tests__/useSuspenseQuery.types.test.d.ts +2 -0
- package/build/lib/__tests__/utils.d.ts +1 -0
- package/build/lib/index.d.ts +3 -0
- package/build/lib/queryOptions.d.ts +14 -0
- package/build/lib/useQueries.d.ts +22 -11
- package/build/lib/useQuery.d.ts +21 -14
- package/build/lib/useSuspenseQueries.d.ts +66 -0
- package/build/lib/useSuspenseQuery.d.ts +8 -0
- package/package.json +3 -10
- package/src/__tests__/queryOptions.types.test.tsx +270 -0
- package/src/__tests__/useQuery.types.test.tsx +1 -2
- package/src/__tests__/useSuspenseQueries.types.test.tsx +102 -0
- package/src/__tests__/useSuspenseQuery.types.test.tsx +81 -0
- package/src/__tests__/utils.tsx +2 -0
- package/src/index.ts +3 -0
- package/src/queryOptions.ts +86 -0
- package/src/useQueries.ts +50 -22
- package/src/useQuery.ts +55 -22
- package/src/useSuspenseQueries.ts +162 -0
- package/src/useSuspenseQuery.ts +58 -0
- package/build/lib/Hydrate.esm.js +0 -32
- package/build/lib/Hydrate.esm.js.map +0 -1
- package/build/lib/Hydrate.js +0 -57
- package/build/lib/Hydrate.js.map +0 -1
- package/build/lib/Hydrate.mjs +0 -32
- package/build/lib/Hydrate.mjs.map +0 -1
- package/build/lib/QueryClientProvider.esm.js +0 -66
- package/build/lib/QueryClientProvider.esm.js.map +0 -1
- package/build/lib/QueryClientProvider.js +0 -92
- package/build/lib/QueryClientProvider.js.map +0 -1
- package/build/lib/QueryClientProvider.mjs +0 -66
- package/build/lib/QueryClientProvider.mjs.map +0 -1
- package/build/lib/QueryErrorResetBoundary.esm.js +0 -33
- package/build/lib/QueryErrorResetBoundary.esm.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.js +0 -58
- package/build/lib/QueryErrorResetBoundary.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.mjs +0 -33
- package/build/lib/QueryErrorResetBoundary.mjs.map +0 -1
- package/build/lib/errorBoundaryUtils.esm.js +0 -28
- package/build/lib/errorBoundaryUtils.esm.js.map +0 -1
- package/build/lib/errorBoundaryUtils.js +0 -54
- package/build/lib/errorBoundaryUtils.js.map +0 -1
- package/build/lib/errorBoundaryUtils.mjs +0 -28
- package/build/lib/errorBoundaryUtils.mjs.map +0 -1
- package/build/lib/index.esm.js +0 -13
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -41
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -13
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/isRestoring.esm.js +0 -9
- package/build/lib/isRestoring.esm.js.map +0 -1
- package/build/lib/isRestoring.js +0 -34
- package/build/lib/isRestoring.js.map +0 -1
- package/build/lib/isRestoring.mjs +0 -9
- package/build/lib/isRestoring.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.esm.js +0 -7
- package/build/lib/reactBatchedUpdates.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.js +0 -31
- package/build/lib/reactBatchedUpdates.js.map +0 -1
- package/build/lib/reactBatchedUpdates.mjs +0 -7
- package/build/lib/reactBatchedUpdates.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.native.esm.js +0 -2
- package/build/lib/reactBatchedUpdates.native.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.native.js +0 -13
- package/build/lib/reactBatchedUpdates.native.js.map +0 -1
- package/build/lib/reactBatchedUpdates.native.mjs +0 -2
- package/build/lib/reactBatchedUpdates.native.mjs.map +0 -1
- package/build/lib/setBatchUpdatesFn.esm.js +0 -5
- package/build/lib/setBatchUpdatesFn.esm.js.map +0 -1
- package/build/lib/setBatchUpdatesFn.js +0 -7
- package/build/lib/setBatchUpdatesFn.js.map +0 -1
- package/build/lib/setBatchUpdatesFn.mjs +0 -5
- package/build/lib/setBatchUpdatesFn.mjs.map +0 -1
- package/build/lib/suspense.esm.js +0 -24
- package/build/lib/suspense.esm.js.map +0 -1
- package/build/lib/suspense.js +0 -31
- package/build/lib/suspense.js.map +0 -1
- package/build/lib/suspense.mjs +0 -24
- package/build/lib/suspense.mjs.map +0 -1
- package/build/lib/useBaseQuery.esm.js +0 -72
- package/build/lib/useBaseQuery.esm.js.map +0 -1
- package/build/lib/useBaseQuery.js +0 -96
- package/build/lib/useBaseQuery.js.map +0 -1
- package/build/lib/useBaseQuery.mjs +0 -72
- package/build/lib/useBaseQuery.mjs.map +0 -1
- package/build/lib/useInfiniteQuery.esm.js +0 -11
- package/build/lib/useInfiniteQuery.esm.js.map +0 -1
- package/build/lib/useInfiniteQuery.js +0 -15
- package/build/lib/useInfiniteQuery.js.map +0 -1
- package/build/lib/useInfiniteQuery.mjs +0 -11
- package/build/lib/useInfiniteQuery.mjs.map +0 -1
- package/build/lib/useIsFetching.esm.js +0 -17
- package/build/lib/useIsFetching.esm.js.map +0 -1
- package/build/lib/useIsFetching.js +0 -41
- package/build/lib/useIsFetching.js.map +0 -1
- package/build/lib/useIsFetching.mjs +0 -17
- package/build/lib/useIsFetching.mjs.map +0 -1
- package/build/lib/useIsMutating.esm.js +0 -17
- package/build/lib/useIsMutating.esm.js.map +0 -1
- package/build/lib/useIsMutating.js +0 -41
- package/build/lib/useIsMutating.js.map +0 -1
- package/build/lib/useIsMutating.mjs +0 -17
- package/build/lib/useIsMutating.mjs.map +0 -1
- package/build/lib/useMutation.esm.js +0 -35
- package/build/lib/useMutation.esm.js.map +0 -1
- package/build/lib/useMutation.js +0 -59
- package/build/lib/useMutation.js.map +0 -1
- package/build/lib/useMutation.mjs +0 -35
- package/build/lib/useMutation.mjs.map +0 -1
- package/build/lib/useQueries.esm.js +0 -81
- package/build/lib/useQueries.esm.js.map +0 -1
- package/build/lib/useQueries.js +0 -105
- package/build/lib/useQueries.js.map +0 -1
- package/build/lib/useQueries.mjs +0 -81
- package/build/lib/useQueries.mjs.map +0 -1
- package/build/lib/useQuery.esm.js +0 -11
- package/build/lib/useQuery.esm.js.map +0 -1
- package/build/lib/useQuery.js +0 -15
- package/build/lib/useQuery.js.map +0 -1
- package/build/lib/useQuery.mjs +0 -11
- package/build/lib/useQuery.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.esm.js +0 -7
- package/build/lib/useSyncExternalStore.esm.js.map +0 -1
- package/build/lib/useSyncExternalStore.js +0 -11
- package/build/lib/useSyncExternalStore.js.map +0 -1
- package/build/lib/useSyncExternalStore.mjs +0 -7
- package/build/lib/useSyncExternalStore.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.native.esm.js +0 -2
- package/build/lib/useSyncExternalStore.native.esm.js.map +0 -1
- package/build/lib/useSyncExternalStore.native.js +0 -13
- package/build/lib/useSyncExternalStore.native.js.map +0 -1
- package/build/lib/useSyncExternalStore.native.mjs +0 -2
- package/build/lib/useSyncExternalStore.native.mjs.map +0 -1
- package/build/lib/utils.esm.js +0 -11
- package/build/lib/utils.esm.js.map +0 -1
- package/build/lib/utils.js +0 -15
- package/build/lib/utils.js.map +0 -1
- package/build/lib/utils.mjs +0 -11
- package/build/lib/utils.mjs.map +0 -1
- package/build/umd/index.development.js +0 -3961
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -2
- package/build/umd/index.production.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"suspense.mjs","sources":["../../src/suspense.ts"],"sourcesContent":["import type { DefaultedQueryObserverOptions } from '@tanstack/query-core'\nimport type { QueryObserver } from '@tanstack/query-core'\nimport type { QueryErrorResetBoundaryValue } from './QueryErrorResetBoundary'\nimport type { QueryObserverResult } from '@tanstack/query-core'\nimport type { QueryKey } from '@tanstack/query-core'\n\nexport const ensureStaleTime = (\n defaultedOptions: DefaultedQueryObserverOptions<any, any, any, any, any>,\n) => {\n if (defaultedOptions.suspense) {\n // Always set stale time when using suspense to prevent\n // fetching again when directly mounting after suspending\n if (typeof defaultedOptions.staleTime !== 'number') {\n defaultedOptions.staleTime = 1000\n }\n }\n}\n\nexport const willFetch = (\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => result.isLoading && result.isFetching && !isRestoring\n\nexport const shouldSuspend = (\n defaultedOptions:\n | DefaultedQueryObserverOptions<any, any, any, any, any>\n | undefined,\n result: QueryObserverResult<any, any>,\n isRestoring: boolean,\n) => defaultedOptions?.suspense && willFetch(result, isRestoring)\n\nexport const fetchOptimistic = <\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n defaultedOptions: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n errorResetBoundary: QueryErrorResetBoundaryValue,\n) =>\n observer\n .fetchOptimistic(defaultedOptions)\n .then(({ data }) => {\n defaultedOptions.onSuccess?.(data as TData)\n defaultedOptions.onSettled?.(data, null)\n })\n .catch((error) => {\n errorResetBoundary.clearReset()\n defaultedOptions.onError?.(error)\n defaultedOptions.onSettled?.(undefined, error)\n })\n"],"names":["ensureStaleTime","defaultedOptions","suspense","staleTime","willFetch","result","isRestoring","isLoading","isFetching","shouldSuspend","fetchOptimistic","observer","errorResetBoundary","then","data","onSuccess","onSettled","catch","error","clearReset","onError","undefined"],"mappings":"AAMaA,MAAAA,eAAe,GAC1BC,gBAD6B,IAE1B;EACH,IAAIA,gBAAgB,CAACC,QAArB,EAA+B;AAC7B;AACA;AACA,IAAA,IAAI,OAAOD,gBAAgB,CAACE,SAAxB,KAAsC,QAA1C,EAAoD;MAClDF,gBAAgB,CAACE,SAAjB,GAA6B,IAA7B,CAAA;AACD,KAAA;AACF,GAAA;AACF,EAVM;MAYMC,SAAS,GAAG,CACvBC,MADuB,EAEvBC,WAFuB,KAGpBD,MAAM,CAACE,SAAP,IAAoBF,MAAM,CAACG,UAA3B,IAAyC,CAACF,YAHxC;AAKA,MAAMG,aAAa,GAAG,CAC3BR,gBAD2B,EAI3BI,MAJ2B,EAK3BC,WAL2B,KAMxB,CAAAL,gBAAgB,IAAhB,IAAA,GAAA,KAAA,CAAA,GAAAA,gBAAgB,CAAEC,QAAlB,KAA8BE,SAAS,CAACC,MAAD,EAASC,WAAT,EANrC;MAQMI,eAAe,GAAG,CAO7BT,gBAP6B,EAc7BU,QAd6B,EAe7BC,kBAf6B,KAiB7BD,QAAQ,CACLD,eADH,CACmBT,gBADnB,CAEGY,CAAAA,IAFH,CAEQ,CAAC;AAAEC,EAAAA,IAAAA;AAAF,CAAD,KAAc;AAClBb,EAAAA,gBAAgB,CAACc,SAAjB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAd,gBAAgB,CAACc,SAAjB,CAA6BD,IAA7B,CAAA,CAAA;EACAb,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BF,IAA7B,EAAmC,IAAnC,CAAA,CAAA;AACD,CALH,CAMGG,CAAAA,KANH,CAMUC,KAAD,IAAW;AAChBN,EAAAA,kBAAkB,CAACO,UAAnB,EAAA,CAAA;AACAlB,EAAAA,gBAAgB,CAACmB,OAAjB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAnB,gBAAgB,CAACmB,OAAjB,CAA2BF,KAA3B,CAAA,CAAA;EACAjB,gBAAgB,CAACe,SAAjB,IAAAf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAgB,CAACe,SAAjB,CAA6BK,SAA7B,EAAwCH,KAAxC,CAAA,CAAA;AACD,CAVH;;;;"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.esm.js';
|
|
5
|
-
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary.esm.js';
|
|
6
|
-
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
7
|
-
import { useIsRestoring } from './isRestoring.esm.js';
|
|
8
|
-
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from './errorBoundaryUtils.esm.js';
|
|
9
|
-
import { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense.esm.js';
|
|
10
|
-
|
|
11
|
-
function useBaseQuery(options, Observer) {
|
|
12
|
-
const queryClient = useQueryClient({
|
|
13
|
-
context: options.context
|
|
14
|
-
});
|
|
15
|
-
const isRestoring = useIsRestoring();
|
|
16
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
17
|
-
const defaultedOptions = queryClient.defaultQueryOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
|
|
18
|
-
|
|
19
|
-
defaultedOptions._optimisticResults = isRestoring ? 'isRestoring' : 'optimistic'; // Include callbacks in batch renders
|
|
20
|
-
|
|
21
|
-
if (defaultedOptions.onError) {
|
|
22
|
-
defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (defaultedOptions.onSuccess) {
|
|
26
|
-
defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (defaultedOptions.onSettled) {
|
|
30
|
-
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
ensureStaleTime(defaultedOptions);
|
|
34
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
35
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
36
|
-
const [observer] = React.useState(() => new Observer(queryClient, defaultedOptions));
|
|
37
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
38
|
-
useSyncExternalStore(React.useCallback(onStoreChange => {
|
|
39
|
-
const unsubscribe = isRestoring ? () => undefined : observer.subscribe(notifyManager.batchCalls(onStoreChange)); // Update result to make sure we did not miss any query updates
|
|
40
|
-
// between creating the observer and subscribing to it.
|
|
41
|
-
|
|
42
|
-
observer.updateResult();
|
|
43
|
-
return unsubscribe;
|
|
44
|
-
}, [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
// Do not notify on updates because of changes in the options because
|
|
47
|
-
// these changes should already be reflected in the optimistic result.
|
|
48
|
-
observer.setOptions(defaultedOptions, {
|
|
49
|
-
listeners: false
|
|
50
|
-
});
|
|
51
|
-
}, [defaultedOptions, observer]); // Handle suspense
|
|
52
|
-
|
|
53
|
-
if (shouldSuspend(defaultedOptions, result, isRestoring)) {
|
|
54
|
-
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
55
|
-
} // Handle error boundary
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (getHasError({
|
|
59
|
-
result,
|
|
60
|
-
errorResetBoundary,
|
|
61
|
-
useErrorBoundary: defaultedOptions.useErrorBoundary,
|
|
62
|
-
query: observer.getCurrentQuery()
|
|
63
|
-
})) {
|
|
64
|
-
throw result.error;
|
|
65
|
-
} // Handle result property usage tracking
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { useBaseQuery };
|
|
72
|
-
//# sourceMappingURL=useBaseQuery.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.esm.js","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { notifyManager } from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, fetchOptimistic, shouldSuspend } from './suspense'\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport type { UseBaseQueryOptions } from './types'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange))\n\n // Update result to make sure we did not miss any query updates\n // between creating the observer and subscribing to it.\n observer.updateResult()\n\n return unsubscribe\n },\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["ensurePreventErrorBoundaryRetry","useSyncExternalStore","observer","listeners"],"mappings":";;;;;;;;;;AAiBO;;;AAgB8B;;;;;;;;;AAelC;;;;AAMA;;;;AAMA;;;AAGDA;;AAIA;AAQA;AAEAC;AAGM;AAKA;;AACAC;AAEA;AACD;;AAQH;AACA;AACAA;AAAwCC;;AACzC;;;AAIC;AACD;;;AAGD;;;;;AACc;;AAQb;;;AAGD;AAGD;;"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var queryCore = require('@tanstack/query-core');
|
|
8
|
-
var useSyncExternalStore = require('./useSyncExternalStore');
|
|
9
|
-
var QueryErrorResetBoundary = require('./QueryErrorResetBoundary.js');
|
|
10
|
-
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
11
|
-
var isRestoring = require('./isRestoring.js');
|
|
12
|
-
var errorBoundaryUtils = require('./errorBoundaryUtils.js');
|
|
13
|
-
var suspense = require('./suspense.js');
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n["default"] = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
-
|
|
35
|
-
function useBaseQuery(options, Observer) {
|
|
36
|
-
const queryClient = QueryClientProvider.useQueryClient({
|
|
37
|
-
context: options.context
|
|
38
|
-
});
|
|
39
|
-
const isRestoring$1 = isRestoring.useIsRestoring();
|
|
40
|
-
const errorResetBoundary = QueryErrorResetBoundary.useQueryErrorResetBoundary();
|
|
41
|
-
const defaultedOptions = queryClient.defaultQueryOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
|
|
42
|
-
|
|
43
|
-
defaultedOptions._optimisticResults = isRestoring$1 ? 'isRestoring' : 'optimistic'; // Include callbacks in batch renders
|
|
44
|
-
|
|
45
|
-
if (defaultedOptions.onError) {
|
|
46
|
-
defaultedOptions.onError = queryCore.notifyManager.batchCalls(defaultedOptions.onError);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (defaultedOptions.onSuccess) {
|
|
50
|
-
defaultedOptions.onSuccess = queryCore.notifyManager.batchCalls(defaultedOptions.onSuccess);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (defaultedOptions.onSettled) {
|
|
54
|
-
defaultedOptions.onSettled = queryCore.notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
suspense.ensureStaleTime(defaultedOptions);
|
|
58
|
-
errorBoundaryUtils.ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
59
|
-
errorBoundaryUtils.useClearResetErrorBoundary(errorResetBoundary);
|
|
60
|
-
const [observer] = React__namespace.useState(() => new Observer(queryClient, defaultedOptions));
|
|
61
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
62
|
-
useSyncExternalStore.useSyncExternalStore(React__namespace.useCallback(onStoreChange => {
|
|
63
|
-
const unsubscribe = isRestoring$1 ? () => undefined : observer.subscribe(queryCore.notifyManager.batchCalls(onStoreChange)); // Update result to make sure we did not miss any query updates
|
|
64
|
-
// between creating the observer and subscribing to it.
|
|
65
|
-
|
|
66
|
-
observer.updateResult();
|
|
67
|
-
return unsubscribe;
|
|
68
|
-
}, [observer, isRestoring$1]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
69
|
-
React__namespace.useEffect(() => {
|
|
70
|
-
// Do not notify on updates because of changes in the options because
|
|
71
|
-
// these changes should already be reflected in the optimistic result.
|
|
72
|
-
observer.setOptions(defaultedOptions, {
|
|
73
|
-
listeners: false
|
|
74
|
-
});
|
|
75
|
-
}, [defaultedOptions, observer]); // Handle suspense
|
|
76
|
-
|
|
77
|
-
if (suspense.shouldSuspend(defaultedOptions, result, isRestoring$1)) {
|
|
78
|
-
throw suspense.fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
79
|
-
} // Handle error boundary
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (errorBoundaryUtils.getHasError({
|
|
83
|
-
result,
|
|
84
|
-
errorResetBoundary,
|
|
85
|
-
useErrorBoundary: defaultedOptions.useErrorBoundary,
|
|
86
|
-
query: observer.getCurrentQuery()
|
|
87
|
-
})) {
|
|
88
|
-
throw result.error;
|
|
89
|
-
} // Handle result property usage tracking
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.useBaseQuery = useBaseQuery;
|
|
96
|
-
//# sourceMappingURL=useBaseQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.js","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { notifyManager } from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, fetchOptimistic, shouldSuspend } from './suspense'\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport type { UseBaseQueryOptions } from './types'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange))\n\n // Update result to make sure we did not miss any query updates\n // between creating the observer and subscribing to it.\n observer.updateResult()\n\n return unsubscribe\n },\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["ensurePreventErrorBoundaryRetry","useSyncExternalStore","observer","listeners"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO;;;AAgB8B;;;;;;;;;AAelC;;;;AAMA;;;;AAMA;;;AAGDA;;AAIA;AAQA;AAEAC;AAGM;AAKA;;AACAC;AAEA;AACD;;AAQH;AACA;AACAA;AAAwCC;;AACzC;;;AAIC;AACD;;;AAGD;;;;;AACc;;AAQb;;;AAGD;AAGD;;"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.mjs';
|
|
5
|
-
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary.mjs';
|
|
6
|
-
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
7
|
-
import { useIsRestoring } from './isRestoring.mjs';
|
|
8
|
-
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from './errorBoundaryUtils.mjs';
|
|
9
|
-
import { ensureStaleTime, shouldSuspend, fetchOptimistic } from './suspense.mjs';
|
|
10
|
-
|
|
11
|
-
function useBaseQuery(options, Observer) {
|
|
12
|
-
const queryClient = useQueryClient({
|
|
13
|
-
context: options.context
|
|
14
|
-
});
|
|
15
|
-
const isRestoring = useIsRestoring();
|
|
16
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
17
|
-
const defaultedOptions = queryClient.defaultQueryOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
|
|
18
|
-
|
|
19
|
-
defaultedOptions._optimisticResults = isRestoring ? 'isRestoring' : 'optimistic'; // Include callbacks in batch renders
|
|
20
|
-
|
|
21
|
-
if (defaultedOptions.onError) {
|
|
22
|
-
defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (defaultedOptions.onSuccess) {
|
|
26
|
-
defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (defaultedOptions.onSettled) {
|
|
30
|
-
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
ensureStaleTime(defaultedOptions);
|
|
34
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
35
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
36
|
-
const [observer] = React.useState(() => new Observer(queryClient, defaultedOptions));
|
|
37
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
38
|
-
useSyncExternalStore(React.useCallback(onStoreChange => {
|
|
39
|
-
const unsubscribe = isRestoring ? () => undefined : observer.subscribe(notifyManager.batchCalls(onStoreChange)); // Update result to make sure we did not miss any query updates
|
|
40
|
-
// between creating the observer and subscribing to it.
|
|
41
|
-
|
|
42
|
-
observer.updateResult();
|
|
43
|
-
return unsubscribe;
|
|
44
|
-
}, [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
// Do not notify on updates because of changes in the options because
|
|
47
|
-
// these changes should already be reflected in the optimistic result.
|
|
48
|
-
observer.setOptions(defaultedOptions, {
|
|
49
|
-
listeners: false
|
|
50
|
-
});
|
|
51
|
-
}, [defaultedOptions, observer]); // Handle suspense
|
|
52
|
-
|
|
53
|
-
if (shouldSuspend(defaultedOptions, result, isRestoring)) {
|
|
54
|
-
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
55
|
-
} // Handle error boundary
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (getHasError({
|
|
59
|
-
result,
|
|
60
|
-
errorResetBoundary,
|
|
61
|
-
useErrorBoundary: defaultedOptions.useErrorBoundary,
|
|
62
|
-
query: observer.getCurrentQuery()
|
|
63
|
-
})) {
|
|
64
|
-
throw result.error;
|
|
65
|
-
} // Handle result property usage tracking
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { useBaseQuery };
|
|
72
|
-
//# sourceMappingURL=useBaseQuery.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseQuery.mjs","sources":["../../src/useBaseQuery.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { notifyManager } from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, fetchOptimistic, shouldSuspend } from './suspense'\nimport type { QueryKey, QueryObserver } from '@tanstack/query-core'\nimport type { UseBaseQueryOptions } from './types'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n) {\n const queryClient = useQueryClient({ context: options.context })\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n // Include callbacks in batch renders\n if (defaultedOptions.onError) {\n defaultedOptions.onError = notifyManager.batchCalls(\n defaultedOptions.onError,\n )\n }\n\n if (defaultedOptions.onSuccess) {\n defaultedOptions.onSuccess = notifyManager.batchCalls(\n defaultedOptions.onSuccess,\n )\n }\n\n if (defaultedOptions.onSettled) {\n defaultedOptions.onSettled = notifyManager.batchCalls(\n defaultedOptions.onSettled,\n )\n }\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n queryClient,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange))\n\n // Update result to make sure we did not miss any query updates\n // between creating the observer and subscribing to it.\n observer.updateResult()\n\n return unsubscribe\n },\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n useErrorBoundary: defaultedOptions.useErrorBoundary,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"names":["ensurePreventErrorBoundaryRetry","useSyncExternalStore","observer","listeners"],"mappings":";;;;;;;;;;AAiBO;;;AAgB8B;;;;;;;;;AAelC;;;;AAMA;;;;AAMA;;;AAGDA;;AAIA;AAQA;AAEAC;AAGM;AAKA;;AACAC;AAEA;AACD;;AAQH;AACA;AACAA;AAAwCC;;AACzC;;;AAIC;AACD;;;AAGD;;;;;AACc;;AAQb;;;AAGD;AAGD;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { parseQueryArgs, InfiniteQueryObserver } from '@tanstack/query-core';
|
|
3
|
-
import { useBaseQuery } from './useBaseQuery.esm.js';
|
|
4
|
-
|
|
5
|
-
function useInfiniteQuery(arg1, arg2, arg3) {
|
|
6
|
-
const options = parseQueryArgs(arg1, arg2, arg3);
|
|
7
|
-
return useBaseQuery(options, InfiniteQueryObserver);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { useInfiniteQuery };
|
|
11
|
-
//# sourceMappingURL=useInfiniteQuery.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.esm.js","sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["'use client'\nimport { InfiniteQueryObserver, parseQueryArgs } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n QueryFunction,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'\n\n// HOOK\n\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n queryKey: TQueryKey,\n options?: Omit<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n 'queryKey'\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n queryKey: TQueryKey,\n queryFn: QueryFunction<TQueryFnData, TQueryKey>,\n options?: Omit<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n 'queryKey' | 'queryFn'\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData,\n TError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n arg1:\n | TQueryKey\n | UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n arg2?:\n | QueryFunction<TQueryFnData, TQueryKey>\n | UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n arg3?: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n): UseInfiniteQueryResult<TData, TError> {\n const options = parseQueryArgs(arg1, arg2, arg3)\n return useBaseQuery(\n options,\n InfiniteQueryObserver as typeof QueryObserver,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n"],"names":[],"mappings":";;;;AA+DO;;AAiCL;AAID;;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var queryCore = require('@tanstack/query-core');
|
|
7
|
-
var useBaseQuery = require('./useBaseQuery.js');
|
|
8
|
-
|
|
9
|
-
function useInfiniteQuery(arg1, arg2, arg3) {
|
|
10
|
-
const options = queryCore.parseQueryArgs(arg1, arg2, arg3);
|
|
11
|
-
return useBaseQuery.useBaseQuery(options, queryCore.InfiniteQueryObserver);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
exports.useInfiniteQuery = useInfiniteQuery;
|
|
15
|
-
//# sourceMappingURL=useInfiniteQuery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.js","sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["'use client'\nimport { InfiniteQueryObserver, parseQueryArgs } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n QueryFunction,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'\n\n// HOOK\n\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n queryKey: TQueryKey,\n options?: Omit<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n 'queryKey'\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n queryKey: TQueryKey,\n queryFn: QueryFunction<TQueryFnData, TQueryKey>,\n options?: Omit<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n 'queryKey' | 'queryFn'\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData,\n TError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n arg1:\n | TQueryKey\n | UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n arg2?:\n | QueryFunction<TQueryFnData, TQueryKey>\n | UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n arg3?: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n): UseInfiniteQueryResult<TData, TError> {\n const options = parseQueryArgs(arg1, arg2, arg3)\n return useBaseQuery(\n options,\n InfiniteQueryObserver as typeof QueryObserver,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n"],"names":[],"mappings":";;;;;;;;AA+DO;;AAiCL;AAID;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { parseQueryArgs, InfiniteQueryObserver } from '@tanstack/query-core';
|
|
3
|
-
import { useBaseQuery } from './useBaseQuery.mjs';
|
|
4
|
-
|
|
5
|
-
function useInfiniteQuery(arg1, arg2, arg3) {
|
|
6
|
-
const options = parseQueryArgs(arg1, arg2, arg3);
|
|
7
|
-
return useBaseQuery(options, InfiniteQueryObserver);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { useInfiniteQuery };
|
|
11
|
-
//# sourceMappingURL=useInfiniteQuery.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteQuery.mjs","sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["'use client'\nimport { InfiniteQueryObserver, parseQueryArgs } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n QueryFunction,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'\n\n// HOOK\n\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n queryKey: TQueryKey,\n options?: Omit<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n 'queryKey'\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n queryKey: TQueryKey,\n queryFn: QueryFunction<TQueryFnData, TQueryKey>,\n options?: Omit<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n 'queryKey' | 'queryFn'\n >,\n): UseInfiniteQueryResult<TData, TError>\nexport function useInfiniteQuery<\n TQueryFnData,\n TError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n arg1:\n | TQueryKey\n | UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n arg2?:\n | QueryFunction<TQueryFnData, TQueryKey>\n | UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n arg3?: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n): UseInfiniteQueryResult<TData, TError> {\n const options = parseQueryArgs(arg1, arg2, arg3)\n return useBaseQuery(\n options,\n InfiniteQueryObserver as typeof QueryObserver,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n"],"names":[],"mappings":";;;;AA+DO;;AAiCL;AAID;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { parseFilterArgs, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.esm.js';
|
|
5
|
-
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
6
|
-
|
|
7
|
-
function useIsFetching(arg1, arg2, arg3) {
|
|
8
|
-
const [filters, options = {}] = parseFilterArgs(arg1, arg2, arg3);
|
|
9
|
-
const queryClient = useQueryClient({
|
|
10
|
-
context: options.context
|
|
11
|
-
});
|
|
12
|
-
const queryCache = queryClient.getQueryCache();
|
|
13
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => queryCache.subscribe(notifyManager.batchCalls(onStoreChange)), [queryCache]), () => queryClient.isFetching(filters), () => queryClient.isFetching(filters));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { useIsFetching };
|
|
17
|
-
//# sourceMappingURL=useIsFetching.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.esm.js","sources":["../../src/useIsFetching.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager, parseFilterArgs } from '@tanstack/query-core'\n\nimport { useSyncExternalStore } from './useSyncExternalStore'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { ContextOptions } from './types'\nimport type { QueryFilters, QueryKey } from '@tanstack/query-core'\n\ninterface Options extends ContextOptions {}\n\nexport function useIsFetching(filters?: QueryFilters, options?: Options): number\nexport function useIsFetching(\n queryKey?: QueryKey,\n filters?: QueryFilters,\n options?: Options,\n): number\nexport function useIsFetching(\n arg1?: QueryKey | QueryFilters,\n arg2?: QueryFilters | Options,\n arg3?: Options,\n): number {\n const [filters, options = {}] = parseFilterArgs(arg1, arg2, arg3)\n const queryClient = useQueryClient({ context: options.context })\n const queryCache = queryClient.getQueryCache()\n\n return useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => queryClient.isFetching(filters),\n () => queryClient.isFetching(filters),\n )\n}\n"],"names":[],"mappings":";;;;;;AAiBO;AAKL;;;AACmC;AACnC;AAEA;AASD;;"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var queryCore = require('@tanstack/query-core');
|
|
8
|
-
var useSyncExternalStore = require('./useSyncExternalStore');
|
|
9
|
-
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
10
|
-
|
|
11
|
-
function _interopNamespace(e) {
|
|
12
|
-
if (e && e.__esModule) return e;
|
|
13
|
-
var n = Object.create(null);
|
|
14
|
-
if (e) {
|
|
15
|
-
Object.keys(e).forEach(function (k) {
|
|
16
|
-
if (k !== 'default') {
|
|
17
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () { return e[k]; }
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
n["default"] = e;
|
|
26
|
-
return Object.freeze(n);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
-
|
|
31
|
-
function useIsFetching(arg1, arg2, arg3) {
|
|
32
|
-
const [filters, options = {}] = queryCore.parseFilterArgs(arg1, arg2, arg3);
|
|
33
|
-
const queryClient = QueryClientProvider.useQueryClient({
|
|
34
|
-
context: options.context
|
|
35
|
-
});
|
|
36
|
-
const queryCache = queryClient.getQueryCache();
|
|
37
|
-
return useSyncExternalStore.useSyncExternalStore(React__namespace.useCallback(onStoreChange => queryCache.subscribe(queryCore.notifyManager.batchCalls(onStoreChange)), [queryCache]), () => queryClient.isFetching(filters), () => queryClient.isFetching(filters));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.useIsFetching = useIsFetching;
|
|
41
|
-
//# sourceMappingURL=useIsFetching.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.js","sources":["../../src/useIsFetching.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager, parseFilterArgs } from '@tanstack/query-core'\n\nimport { useSyncExternalStore } from './useSyncExternalStore'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { ContextOptions } from './types'\nimport type { QueryFilters, QueryKey } from '@tanstack/query-core'\n\ninterface Options extends ContextOptions {}\n\nexport function useIsFetching(filters?: QueryFilters, options?: Options): number\nexport function useIsFetching(\n queryKey?: QueryKey,\n filters?: QueryFilters,\n options?: Options,\n): number\nexport function useIsFetching(\n arg1?: QueryKey | QueryFilters,\n arg2?: QueryFilters | Options,\n arg3?: Options,\n): number {\n const [filters, options = {}] = parseFilterArgs(arg1, arg2, arg3)\n const queryClient = useQueryClient({ context: options.context })\n const queryCache = queryClient.getQueryCache()\n\n return useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => queryClient.isFetching(filters),\n () => queryClient.isFetching(filters),\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO;AAKL;;;AACmC;AACnC;AAEA;AASD;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { parseFilterArgs, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.mjs';
|
|
5
|
-
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
6
|
-
|
|
7
|
-
function useIsFetching(arg1, arg2, arg3) {
|
|
8
|
-
const [filters, options = {}] = parseFilterArgs(arg1, arg2, arg3);
|
|
9
|
-
const queryClient = useQueryClient({
|
|
10
|
-
context: options.context
|
|
11
|
-
});
|
|
12
|
-
const queryCache = queryClient.getQueryCache();
|
|
13
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => queryCache.subscribe(notifyManager.batchCalls(onStoreChange)), [queryCache]), () => queryClient.isFetching(filters), () => queryClient.isFetching(filters));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { useIsFetching };
|
|
17
|
-
//# sourceMappingURL=useIsFetching.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.mjs","sources":["../../src/useIsFetching.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager, parseFilterArgs } from '@tanstack/query-core'\n\nimport { useSyncExternalStore } from './useSyncExternalStore'\nimport { useQueryClient } from './QueryClientProvider'\nimport type { ContextOptions } from './types'\nimport type { QueryFilters, QueryKey } from '@tanstack/query-core'\n\ninterface Options extends ContextOptions {}\n\nexport function useIsFetching(filters?: QueryFilters, options?: Options): number\nexport function useIsFetching(\n queryKey?: QueryKey,\n filters?: QueryFilters,\n options?: Options,\n): number\nexport function useIsFetching(\n arg1?: QueryKey | QueryFilters,\n arg2?: QueryFilters | Options,\n arg3?: Options,\n): number {\n const [filters, options = {}] = parseFilterArgs(arg1, arg2, arg3)\n const queryClient = useQueryClient({ context: options.context })\n const queryCache = queryClient.getQueryCache()\n\n return useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => queryClient.isFetching(filters),\n () => queryClient.isFetching(filters),\n )\n}\n"],"names":[],"mappings":";;;;;;AAiBO;AAKL;;;AACmC;AACnC;AAEA;AASD;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { parseMutationFilterArgs, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.esm.js';
|
|
5
|
-
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
6
|
-
|
|
7
|
-
function useIsMutating(arg1, arg2, arg3) {
|
|
8
|
-
const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3);
|
|
9
|
-
const queryClient = useQueryClient({
|
|
10
|
-
context: options.context
|
|
11
|
-
});
|
|
12
|
-
const mutationCache = queryClient.getMutationCache();
|
|
13
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)), [mutationCache]), () => queryClient.isMutating(filters), () => queryClient.isMutating(filters));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { useIsMutating };
|
|
17
|
-
//# sourceMappingURL=useIsMutating.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.esm.js","sources":["../../src/useIsMutating.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport type { MutationFilters, MutationKey } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ninterface Options extends ContextOptions {}\n\nexport function useIsMutating(\n filters?: MutationFilters,\n options?: Options,\n): number\nexport function useIsMutating(\n mutationKey?: MutationKey,\n filters?: Omit<MutationFilters, 'mutationKey'>,\n options?: Options,\n): number\nexport function useIsMutating(\n arg1?: MutationKey | MutationFilters,\n arg2?: Omit<MutationFilters, 'mutationKey'> | Options,\n arg3?: Options,\n): number {\n const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3)\n\n const queryClient = useQueryClient({ context: options.context })\n const mutationCache = queryClient.getMutationCache()\n\n return useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [mutationCache],\n ),\n () => queryClient.isMutating(filters),\n () => queryClient.isMutating(filters),\n )\n}\n"],"names":[],"mappings":";;;;;;AAoBO;AAKL;;;AAEmC;AACnC;AAEA;AASD;;"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var queryCore = require('@tanstack/query-core');
|
|
8
|
-
var useSyncExternalStore = require('./useSyncExternalStore');
|
|
9
|
-
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
10
|
-
|
|
11
|
-
function _interopNamespace(e) {
|
|
12
|
-
if (e && e.__esModule) return e;
|
|
13
|
-
var n = Object.create(null);
|
|
14
|
-
if (e) {
|
|
15
|
-
Object.keys(e).forEach(function (k) {
|
|
16
|
-
if (k !== 'default') {
|
|
17
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () { return e[k]; }
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
n["default"] = e;
|
|
26
|
-
return Object.freeze(n);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
-
|
|
31
|
-
function useIsMutating(arg1, arg2, arg3) {
|
|
32
|
-
const [filters, options = {}] = queryCore.parseMutationFilterArgs(arg1, arg2, arg3);
|
|
33
|
-
const queryClient = QueryClientProvider.useQueryClient({
|
|
34
|
-
context: options.context
|
|
35
|
-
});
|
|
36
|
-
const mutationCache = queryClient.getMutationCache();
|
|
37
|
-
return useSyncExternalStore.useSyncExternalStore(React__namespace.useCallback(onStoreChange => mutationCache.subscribe(queryCore.notifyManager.batchCalls(onStoreChange)), [mutationCache]), () => queryClient.isMutating(filters), () => queryClient.isMutating(filters));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.useIsMutating = useIsMutating;
|
|
41
|
-
//# sourceMappingURL=useIsMutating.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.js","sources":["../../src/useIsMutating.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport type { MutationFilters, MutationKey } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ninterface Options extends ContextOptions {}\n\nexport function useIsMutating(\n filters?: MutationFilters,\n options?: Options,\n): number\nexport function useIsMutating(\n mutationKey?: MutationKey,\n filters?: Omit<MutationFilters, 'mutationKey'>,\n options?: Options,\n): number\nexport function useIsMutating(\n arg1?: MutationKey | MutationFilters,\n arg2?: Omit<MutationFilters, 'mutationKey'> | Options,\n arg3?: Options,\n): number {\n const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3)\n\n const queryClient = useQueryClient({ context: options.context })\n const mutationCache = queryClient.getMutationCache()\n\n return useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [mutationCache],\n ),\n () => queryClient.isMutating(filters),\n () => queryClient.isMutating(filters),\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO;AAKL;;;AAEmC;AACnC;AAEA;AASD;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { parseMutationFilterArgs, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.mjs';
|
|
5
|
-
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
6
|
-
|
|
7
|
-
function useIsMutating(arg1, arg2, arg3) {
|
|
8
|
-
const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3);
|
|
9
|
-
const queryClient = useQueryClient({
|
|
10
|
-
context: options.context
|
|
11
|
-
});
|
|
12
|
-
const mutationCache = queryClient.getMutationCache();
|
|
13
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)), [mutationCache]), () => queryClient.isMutating(filters), () => queryClient.isMutating(filters));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { useIsMutating };
|
|
17
|
-
//# sourceMappingURL=useIsMutating.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.mjs","sources":["../../src/useIsMutating.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport type { MutationFilters, MutationKey } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\n\ninterface Options extends ContextOptions {}\n\nexport function useIsMutating(\n filters?: MutationFilters,\n options?: Options,\n): number\nexport function useIsMutating(\n mutationKey?: MutationKey,\n filters?: Omit<MutationFilters, 'mutationKey'>,\n options?: Options,\n): number\nexport function useIsMutating(\n arg1?: MutationKey | MutationFilters,\n arg2?: Omit<MutationFilters, 'mutationKey'> | Options,\n arg3?: Options,\n): number {\n const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3)\n\n const queryClient = useQueryClient({ context: options.context })\n const mutationCache = queryClient.getMutationCache()\n\n return useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [mutationCache],\n ),\n () => queryClient.isMutating(filters),\n () => queryClient.isMutating(filters),\n )\n}\n"],"names":[],"mappings":";;;;;;AAoBO;AAKL;;;AAEmC;AACnC;AAEA;AASD;;"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { parseMutationArgs, MutationObserver, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useSyncExternalStore } from './useSyncExternalStore.esm.js';
|
|
5
|
-
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
6
|
-
import { shouldThrowError } from './utils.esm.js';
|
|
7
|
-
|
|
8
|
-
function useMutation(arg1, arg2, arg3) {
|
|
9
|
-
const options = parseMutationArgs(arg1, arg2, arg3);
|
|
10
|
-
const queryClient = useQueryClient({
|
|
11
|
-
context: options.context
|
|
12
|
-
});
|
|
13
|
-
const [observer] = React.useState(() => new MutationObserver(queryClient, options));
|
|
14
|
-
React.useEffect(() => {
|
|
15
|
-
observer.setOptions(options);
|
|
16
|
-
}, [observer, options]);
|
|
17
|
-
const result = useSyncExternalStore(React.useCallback(onStoreChange => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
18
|
-
const mutate = React.useCallback((variables, mutateOptions) => {
|
|
19
|
-
observer.mutate(variables, mutateOptions).catch(noop);
|
|
20
|
-
}, [observer]);
|
|
21
|
-
|
|
22
|
-
if (result.error && shouldThrowError(observer.options.useErrorBoundary, [result.error])) {
|
|
23
|
-
throw result.error;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return { ...result,
|
|
27
|
-
mutate,
|
|
28
|
-
mutateAsync: result.mutate
|
|
29
|
-
};
|
|
30
|
-
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
31
|
-
|
|
32
|
-
function noop() {}
|
|
33
|
-
|
|
34
|
-
export { useMutation };
|
|
35
|
-
//# sourceMappingURL=useMutation.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.esm.js","sources":["../../src/useMutation.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport {\n MutationObserver,\n notifyManager,\n parseMutationArgs,\n} from '@tanstack/query-core'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport { shouldThrowError } from './utils'\nimport type { MutationFunction, MutationKey } from '@tanstack/query-core'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\n\n// HOOK\n\nexport function useMutation<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TContext>,\n): UseMutationResult<TData, TError, TVariables, TContext>\nexport function useMutation<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n>(\n mutationFn: MutationFunction<TData, TVariables>,\n options?: Omit<\n UseMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationFn'\n >,\n): UseMutationResult<TData, TError, TVariables, TContext>\nexport function useMutation<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n>(\n mutationKey: MutationKey,\n options?: Omit<\n UseMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n >,\n): UseMutationResult<TData, TError, TVariables, TContext>\nexport function useMutation<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n>(\n mutationKey: MutationKey,\n mutationFn?: MutationFunction<TData, TVariables>,\n options?: Omit<\n UseMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey' | 'mutationFn'\n >,\n): UseMutationResult<TData, TError, TVariables, TContext>\nexport function useMutation<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n>(\n arg1:\n | MutationKey\n | MutationFunction<TData, TVariables>\n | UseMutationOptions<TData, TError, TVariables, TContext>,\n arg2?:\n | MutationFunction<TData, TVariables>\n | UseMutationOptions<TData, TError, TVariables, TContext>,\n arg3?: UseMutationOptions<TData, TError, TVariables, TContext>,\n): UseMutationResult<TData, TError, TVariables, TContext> {\n const options = parseMutationArgs(arg1, arg2, arg3)\n const queryClient = useQueryClient({ context: options.context })\n\n const [observer] = React.useState(\n () =>\n new MutationObserver<TData, TError, TVariables, TContext>(\n queryClient,\n options,\n ),\n )\n\n React.useEffect(() => {\n observer.setOptions(options)\n }, [observer, options])\n\n const result = useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n const mutate = React.useCallback<\n UseMutateFunction<TData, TError, TVariables, TContext>\n >(\n (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n },\n [observer],\n )\n\n if (\n result.error &&\n shouldThrowError(observer.options.useErrorBoundary, [result.error])\n ) {\n throw result.error\n }\n\n return { ...result, mutate, mutateAsync: result.mutate }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction noop() {}\n"],"names":[],"mappings":";;;;;;;AAiEO;;;;AAgB8B;AAEnC;;;AAUC;AAED;;;AAeG;;AAIH;;AAKC;;;;;;AAGF;;AAGD;;"}
|