@tanstack/react-query 4.24.10 → 5.0.0-alpha.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/HydrationBoundary.d.ts +9 -0
- package/build/lib/{Hydrate.esm.js → HydrationBoundary.esm.js} +14 -17
- package/build/lib/HydrationBoundary.esm.js.map +1 -0
- package/build/lib/{Hydrate.js → HydrationBoundary.js} +17 -24
- package/build/lib/HydrationBoundary.js.map +1 -0
- package/build/lib/{Hydrate.mjs → HydrationBoundary.mjs} +14 -17
- package/build/lib/HydrationBoundary.mjs.map +1 -0
- package/build/lib/QueryClientProvider.d.ts +4 -19
- package/build/lib/QueryClientProvider.esm.js +11 -46
- package/build/lib/QueryClientProvider.esm.js.map +1 -1
- package/build/lib/QueryClientProvider.js +14 -52
- package/build/lib/QueryClientProvider.js.map +1 -1
- package/build/lib/QueryClientProvider.mjs +11 -46
- package/build/lib/QueryClientProvider.mjs.map +1 -1
- package/build/lib/QueryErrorResetBoundary.esm.js +7 -2
- package/build/lib/QueryErrorResetBoundary.esm.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.js +10 -8
- package/build/lib/QueryErrorResetBoundary.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.mjs +7 -2
- package/build/lib/QueryErrorResetBoundary.mjs.map +1 -1
- package/build/lib/__tests__/useQuery.types.test.d.ts +1 -2
- package/build/lib/__tests__/utils.d.ts +7 -10
- package/build/lib/errorBoundaryUtils.d.ts +3 -3
- package/build/lib/errorBoundaryUtils.esm.js +3 -3
- package/build/lib/errorBoundaryUtils.esm.js.map +1 -1
- package/build/lib/errorBoundaryUtils.js +6 -9
- package/build/lib/errorBoundaryUtils.js.map +1 -1
- package/build/lib/errorBoundaryUtils.mjs +3 -3
- package/build/lib/errorBoundaryUtils.mjs.map +1 -1
- package/build/lib/index.d.ts +4 -5
- package/build/lib/index.esm.js +3 -4
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +6 -9
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +3 -4
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/isRestoring.esm.js.map +1 -1
- package/build/lib/isRestoring.js +3 -6
- package/build/lib/isRestoring.js.map +1 -1
- package/build/lib/isRestoring.mjs.map +1 -1
- package/build/lib/suspense.esm.js +5 -5
- package/build/lib/suspense.esm.js.map +1 -1
- package/build/lib/suspense.js +5 -7
- package/build/lib/suspense.js.map +1 -1
- package/build/lib/suspense.mjs +5 -5
- package/build/lib/suspense.mjs.map +1 -1
- package/build/lib/types.d.ts +14 -22
- package/build/lib/useBaseQuery.d.ts +2 -2
- package/build/lib/useBaseQuery.esm.js +15 -18
- package/build/lib/useBaseQuery.esm.js.map +1 -1
- package/build/lib/useBaseQuery.js +18 -24
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.mjs +15 -18
- package/build/lib/useBaseQuery.mjs.map +1 -1
- package/build/lib/useInfiniteQuery.d.ts +2 -4
- package/build/lib/useInfiniteQuery.esm.js +4 -4
- package/build/lib/useInfiniteQuery.esm.js.map +1 -1
- package/build/lib/useInfiniteQuery.js +3 -5
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useInfiniteQuery.mjs +4 -4
- package/build/lib/useInfiniteQuery.mjs.map +1 -1
- package/build/lib/useIsFetching.d.ts +2 -7
- package/build/lib/useIsFetching.esm.js +5 -9
- package/build/lib/useIsFetching.esm.js.map +1 -1
- package/build/lib/useIsFetching.js +7 -14
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.mjs +5 -9
- package/build/lib/useIsFetching.mjs.map +1 -1
- package/build/lib/useMutation.d.ts +2 -5
- package/build/lib/useMutation.esm.js +12 -14
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +14 -19
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +12 -14
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/useMutationState.d.ts +8 -0
- package/build/lib/useMutationState.esm.js +37 -0
- package/build/lib/useMutationState.esm.js.map +1 -0
- package/build/lib/useMutationState.js +59 -0
- package/build/lib/useMutationState.js.map +1 -0
- package/build/lib/useMutationState.mjs +37 -0
- package/build/lib/useMutationState.mjs.map +1 -0
- package/build/lib/useQueries.d.ts +9 -7
- package/build/lib/useQueries.esm.js +16 -27
- package/build/lib/useQueries.esm.js.map +1 -1
- package/build/lib/useQueries.js +19 -33
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.mjs +16 -27
- package/build/lib/useQueries.mjs.map +1 -1
- package/build/lib/useQuery.d.ts +9 -21
- package/build/lib/useQuery.esm.js +5 -4
- package/build/lib/useQuery.esm.js.map +1 -1
- package/build/lib/useQuery.js +4 -5
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/useQuery.mjs +5 -4
- package/build/lib/useQuery.mjs.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.esm.js +5 -6
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +5 -8
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +5 -6
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +1003 -1827
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +6 -18
- package/src/{Hydrate.tsx → HydrationBoundary.tsx} +17 -18
- package/src/QueryClientProvider.tsx +11 -65
- package/src/__tests__/{Hydrate.test.tsx → HydrationBoundary.test.tsx} +89 -77
- package/src/__tests__/QueryClientProvider.test.tsx +33 -147
- package/src/__tests__/QueryResetErrorBoundary.test.tsx +118 -85
- package/src/__tests__/ssr-hydration.test.tsx +27 -33
- package/src/__tests__/ssr.test.tsx +23 -9
- package/src/__tests__/suspense.test.tsx +194 -171
- package/src/__tests__/useInfiniteQuery.test.tsx +249 -494
- package/src/__tests__/useInfiniteQuery.type.test.tsx +131 -0
- package/src/__tests__/useIsFetching.test.tsx +65 -108
- package/src/__tests__/useMutation.test.tsx +200 -268
- package/src/__tests__/useMutationState.test.tsx +284 -0
- package/src/__tests__/useQueries.test.tsx +43 -347
- package/src/__tests__/useQuery.test.tsx +890 -686
- package/src/__tests__/useQuery.types.test.tsx +23 -24
- package/src/__tests__/utils.tsx +14 -23
- package/src/errorBoundaryUtils.ts +5 -10
- package/src/index.ts +4 -7
- package/src/types.ts +33 -38
- package/src/useBaseQuery.ts +7 -7
- package/src/useInfiniteQuery.ts +12 -77
- package/src/useIsFetching.ts +8 -20
- package/src/useMutation.ts +8 -66
- package/src/useMutationState.ts +81 -0
- package/src/useQueries.ts +29 -21
- package/src/useQuery.ts +27 -104
- package/src/utils.ts +5 -5
- package/build/lib/Hydrate.d.ts +0 -10
- package/build/lib/Hydrate.esm.js.map +0 -1
- package/build/lib/Hydrate.js.map +0 -1
- package/build/lib/Hydrate.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.d.ts +0 -2
- package/build/lib/reactBatchedUpdates.esm.js +0 -6
- package/build/lib/reactBatchedUpdates.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.js +0 -30
- package/build/lib/reactBatchedUpdates.js.map +0 -1
- package/build/lib/reactBatchedUpdates.mjs +0 -6
- package/build/lib/reactBatchedUpdates.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.native.d.ts +0 -2
- 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/useIsMutating.d.ts +0 -7
- package/build/lib/useIsMutating.esm.js +0 -16
- package/build/lib/useIsMutating.esm.js.map +0 -1
- package/build/lib/useIsMutating.js +0 -40
- package/build/lib/useIsMutating.js.map +0 -1
- package/build/lib/useIsMutating.mjs +0 -16
- package/build/lib/useIsMutating.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.d.ts +0 -2
- 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.d.ts +0 -2
- 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/codemods/v4/key-transformation.js +0 -138
- package/codemods/v4/replace-import-specifier.js +0 -25
- package/codemods/v4/utils/index.js +0 -166
- package/codemods/v4/utils/replacers/key-replacer.js +0 -160
- package/codemods/v4/utils/transformers/query-cache-transformer.js +0 -115
- package/codemods/v4/utils/transformers/query-client-transformer.js +0 -49
- package/codemods/v4/utils/transformers/use-query-like-transformer.js +0 -32
- package/codemods/v4/utils/unprocessable-key-error.js +0 -8
- package/src/__tests__/useIsMutating.test.tsx +0 -259
- package/src/reactBatchedUpdates.native.ts +0 -4
- package/src/reactBatchedUpdates.ts +0 -2
- package/src/setBatchUpdatesFn.ts +0 -4
- package/src/useIsMutating.ts +0 -39
- package/src/useSyncExternalStore.native.ts +0 -5
- package/src/useSyncExternalStore.ts +0 -4
- /package/build/lib/__tests__/{Hydrate.test.d.ts → HydrationBoundary.test.d.ts} +0 -0
- /package/build/lib/__tests__/{useIsMutating.test.d.ts → useInfiniteQuery.type.test.d.ts} +0 -0
- /package/build/lib/{setBatchUpdatesFn.d.ts → __tests__/useMutationState.test.d.ts} +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { MutationKey, MutationFilters } from '@tanstack/query-core';
|
|
2
|
-
import type { ContextOptions } from './types';
|
|
3
|
-
interface Options extends ContextOptions {
|
|
4
|
-
}
|
|
5
|
-
export declare function useIsMutating(filters?: MutationFilters, options?: Options): number;
|
|
6
|
-
export declare function useIsMutating(mutationKey?: MutationKey, filters?: Omit<MutationFilters, 'mutationKey'>, options?: Options): number;
|
|
7
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useSyncExternalStore } from './useSyncExternalStore.esm.js';
|
|
3
|
-
import { parseMutationFilterArgs, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
5
|
-
|
|
6
|
-
function useIsMutating(arg1, arg2, arg3) {
|
|
7
|
-
const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3);
|
|
8
|
-
const queryClient = useQueryClient({
|
|
9
|
-
context: options.context
|
|
10
|
-
});
|
|
11
|
-
const mutationCache = queryClient.getMutationCache();
|
|
12
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)), [mutationCache]), () => queryClient.isMutating(filters), () => queryClient.isMutating(filters));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { useIsMutating };
|
|
16
|
-
//# sourceMappingURL=useIsMutating.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.esm.js","sources":["../../src/useIsMutating.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { MutationKey, MutationFilters } from '@tanstack/query-core'\nimport { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\nimport { useQueryClient } from './QueryClientProvider'\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":["useIsMutating","arg1","arg2","arg3","filters","options","parseMutationFilterArgs","queryClient","useQueryClient","context","mutationCache","getMutationCache","useSyncExternalStore","React","useCallback","onStoreChange","subscribe","notifyManager","batchCalls","isMutating"],"mappings":";;;;;AAmBO,SAASA,aAAT,CACLC,IADK,EAELC,IAFK,EAGLC,IAHK,EAIG;AACR,EAAA,MAAM,CAACC,OAAD,EAAUC,OAAO,GAAG,EAApB,CAAA,GAA0BC,uBAAuB,CAACL,IAAD,EAAOC,IAAP,EAAaC,IAAb,CAAvD,CAAA;EAEA,MAAMI,WAAW,GAAGC,cAAc,CAAC;IAAEC,OAAO,EAAEJ,OAAO,CAACI,OAAAA;AAAnB,GAAD,CAAlC,CAAA;AACA,EAAA,MAAMC,aAAa,GAAGH,WAAW,CAACI,gBAAZ,EAAtB,CAAA;AAEA,EAAA,OAAOC,oBAAoB,CACzBC,KAAK,CAACC,WAAN,CACGC,aAAD,IACEL,aAAa,CAACM,SAAd,CAAwBC,aAAa,CAACC,UAAd,CAAyBH,aAAzB,CAAxB,CAFJ,EAGE,CAACL,aAAD,CAHF,CADyB,EAMzB,MAAMH,WAAW,CAACY,UAAZ,CAAuBf,OAAvB,CANmB,EAOzB,MAAMG,WAAW,CAACY,UAAZ,CAAuBf,OAAvB,CAPmB,CAA3B,CAAA;AASD;;;;"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var useSyncExternalStore = require('./useSyncExternalStore');
|
|
7
|
-
var queryCore = require('@tanstack/query-core');
|
|
8
|
-
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
9
|
-
|
|
10
|
-
function _interopNamespace(e) {
|
|
11
|
-
if (e && e.__esModule) return e;
|
|
12
|
-
var n = Object.create(null);
|
|
13
|
-
if (e) {
|
|
14
|
-
Object.keys(e).forEach(function (k) {
|
|
15
|
-
if (k !== 'default') {
|
|
16
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return e[k]; }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
n["default"] = e;
|
|
25
|
-
return Object.freeze(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
|
-
|
|
30
|
-
function useIsMutating(arg1, arg2, arg3) {
|
|
31
|
-
const [filters, options = {}] = queryCore.parseMutationFilterArgs(arg1, arg2, arg3);
|
|
32
|
-
const queryClient = QueryClientProvider.useQueryClient({
|
|
33
|
-
context: options.context
|
|
34
|
-
});
|
|
35
|
-
const mutationCache = queryClient.getMutationCache();
|
|
36
|
-
return useSyncExternalStore.useSyncExternalStore(React__namespace.useCallback(onStoreChange => mutationCache.subscribe(queryCore.notifyManager.batchCalls(onStoreChange)), [mutationCache]), () => queryClient.isMutating(filters), () => queryClient.isMutating(filters));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.useIsMutating = useIsMutating;
|
|
40
|
-
//# sourceMappingURL=useIsMutating.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.js","sources":["../../src/useIsMutating.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { MutationKey, MutationFilters } from '@tanstack/query-core'\nimport { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\nimport { useQueryClient } from './QueryClientProvider'\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":["useIsMutating","arg1","arg2","arg3","filters","options","parseMutationFilterArgs","queryClient","useQueryClient","context","mutationCache","getMutationCache","useSyncExternalStore","React","useCallback","onStoreChange","subscribe","notifyManager","batchCalls","isMutating"],"mappings":"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"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useSyncExternalStore } from './useSyncExternalStore.mjs';
|
|
3
|
-
import { parseMutationFilterArgs, notifyManager } from '@tanstack/query-core';
|
|
4
|
-
import { useQueryClient } from './QueryClientProvider.mjs';
|
|
5
|
-
|
|
6
|
-
function useIsMutating(arg1, arg2, arg3) {
|
|
7
|
-
const [filters, options = {}] = parseMutationFilterArgs(arg1, arg2, arg3);
|
|
8
|
-
const queryClient = useQueryClient({
|
|
9
|
-
context: options.context
|
|
10
|
-
});
|
|
11
|
-
const mutationCache = queryClient.getMutationCache();
|
|
12
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => mutationCache.subscribe(notifyManager.batchCalls(onStoreChange)), [mutationCache]), () => queryClient.isMutating(filters), () => queryClient.isMutating(filters));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { useIsMutating };
|
|
16
|
-
//# sourceMappingURL=useIsMutating.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.mjs","sources":["../../src/useIsMutating.ts"],"sourcesContent":["import * as React from 'react'\nimport { useSyncExternalStore } from './useSyncExternalStore'\n\nimport type { MutationKey, MutationFilters } from '@tanstack/query-core'\nimport { notifyManager, parseMutationFilterArgs } from '@tanstack/query-core'\nimport type { ContextOptions } from './types'\nimport { useQueryClient } from './QueryClientProvider'\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":["useIsMutating","arg1","arg2","arg3","filters","options","parseMutationFilterArgs","queryClient","useQueryClient","context","mutationCache","getMutationCache","useSyncExternalStore","React","useCallback","onStoreChange","subscribe","notifyManager","batchCalls","isMutating"],"mappings":";;;;;AAmBO,SAASA,aAAT,CACLC,IADK,EAELC,IAFK,EAGLC,IAHK,EAIG;AACR,EAAA,MAAM,CAACC,OAAD,EAAUC,OAAO,GAAG,EAApB,CAAA,GAA0BC,uBAAuB,CAACL,IAAD,EAAOC,IAAP,EAAaC,IAAb,CAAvD,CAAA;EAEA,MAAMI,WAAW,GAAGC,cAAc,CAAC;IAAEC,OAAO,EAAEJ,OAAO,CAACI,OAAAA;AAAnB,GAAD,CAAlC,CAAA;AACA,EAAA,MAAMC,aAAa,GAAGH,WAAW,CAACI,gBAAZ,EAAtB,CAAA;AAEA,EAAA,OAAOC,oBAAoB,CACzBC,KAAK,CAACC,WAAN,CACGC,aAAD,IACEL,aAAa,CAACM,SAAd,CAAwBC,aAAa,CAACC,UAAd,CAAyBH,aAAzB,CAAxB,CAFJ,EAGE,CAACL,aAAD,CAHF,CADyB,EAMzB,MAAMH,WAAW,CAACY,UAAZ,CAAuBf,OAAvB,CANmB,EAOzB,MAAMG,WAAW,CAACY,UAAZ,CAAuBf,OAAvB,CAPmB,CAA3B,CAAA;AASD;;;;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useSyncExternalStore as useSyncExternalStore$1 } from 'use-sync-external-store/shim/index.js';
|
|
2
|
-
|
|
3
|
-
// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
|
|
4
|
-
const useSyncExternalStore = useSyncExternalStore$1;
|
|
5
|
-
|
|
6
|
-
export { useSyncExternalStore };
|
|
7
|
-
//# sourceMappingURL=useSyncExternalStore.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.esm.js","sources":["../../src/useSyncExternalStore.ts"],"sourcesContent":["// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601\nimport { useSyncExternalStore as uSES } from 'use-sync-external-store/shim/index.js'\n\nexport const useSyncExternalStore = uSES\n"],"names":["useSyncExternalStore","uSES"],"mappings":";;AAAA;AAGO,MAAMA,oBAAoB,GAAGC;;;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index_js = require('use-sync-external-store/shim/index.js');
|
|
6
|
-
|
|
7
|
-
// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
|
|
8
|
-
const useSyncExternalStore = index_js.useSyncExternalStore;
|
|
9
|
-
|
|
10
|
-
exports.useSyncExternalStore = useSyncExternalStore;
|
|
11
|
-
//# sourceMappingURL=useSyncExternalStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.js","sources":["../../src/useSyncExternalStore.ts"],"sourcesContent":["// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601\nimport { useSyncExternalStore as uSES } from 'use-sync-external-store/shim/index.js'\n\nexport const useSyncExternalStore = uSES\n"],"names":["useSyncExternalStore","uSES"],"mappings":";;;;;;AAAA;AAGO,MAAMA,oBAAoB,GAAGC;;;;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useSyncExternalStore as useSyncExternalStore$1 } from 'use-sync-external-store/shim/index.js';
|
|
2
|
-
|
|
3
|
-
// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
|
|
4
|
-
const useSyncExternalStore = useSyncExternalStore$1;
|
|
5
|
-
|
|
6
|
-
export { useSyncExternalStore };
|
|
7
|
-
//# sourceMappingURL=useSyncExternalStore.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.mjs","sources":["../../src/useSyncExternalStore.ts"],"sourcesContent":["// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601\nimport { useSyncExternalStore as uSES } from 'use-sync-external-store/shim/index.js'\n\nexport const useSyncExternalStore = uSES\n"],"names":["useSyncExternalStore","uSES"],"mappings":";;AAAA;AAGO,MAAMA,oBAAoB,GAAGC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.native.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index_native_js = require('use-sync-external-store/shim/index.native.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, 'useSyncExternalStore', {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return index_native_js.useSyncExternalStore; }
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=useSyncExternalStore.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.native.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.native.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
|
-
const createUtilsObject = require('./utils')
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
4
|
-
const createKeyReplacer = require('./utils/replacers/key-replacer')
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
-
const createUseQueryLikeTransformer = require('./utils/transformers/use-query-like-transformer')
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
-
const createQueryClientTransformer = require('./utils/transformers/query-client-transformer')
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
-
const createQueryCacheTransformer = require('./utils/transformers/query-cache-transformer')
|
|
11
|
-
|
|
12
|
-
const transformQueryClientUsages = ({ jscodeshift, utils, root, filePath }) => {
|
|
13
|
-
const transformer = createQueryClientTransformer({ jscodeshift, utils, root })
|
|
14
|
-
const replacer = createKeyReplacer({ jscodeshift, root, filePath })
|
|
15
|
-
|
|
16
|
-
transformer.execute(
|
|
17
|
-
[
|
|
18
|
-
// Not object syntax-aware methods.
|
|
19
|
-
'getMutationDefaults',
|
|
20
|
-
'getQueriesData',
|
|
21
|
-
'getQueryData',
|
|
22
|
-
'getQueryDefaults',
|
|
23
|
-
'getQueryState',
|
|
24
|
-
'isFetching',
|
|
25
|
-
'setMutationDefaults',
|
|
26
|
-
'setQueriesData',
|
|
27
|
-
'setQueryData',
|
|
28
|
-
'setQueryDefaults',
|
|
29
|
-
// Object syntax-aware methods.
|
|
30
|
-
'cancelQueries',
|
|
31
|
-
'fetchInfiniteQuery',
|
|
32
|
-
'fetchQuery',
|
|
33
|
-
'invalidateQueries',
|
|
34
|
-
'prefetchInfiniteQuery',
|
|
35
|
-
'prefetchQuery',
|
|
36
|
-
'refetchQueries',
|
|
37
|
-
'removeQueries',
|
|
38
|
-
'resetQueries',
|
|
39
|
-
],
|
|
40
|
-
replacer
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const transformUseQueriesUsages = ({ jscodeshift, utils, root }) => {
|
|
45
|
-
const transformer = createUseQueryLikeTransformer({
|
|
46
|
-
jscodeshift,
|
|
47
|
-
utils,
|
|
48
|
-
root,
|
|
49
|
-
})
|
|
50
|
-
const replacer = ({ node }) => {
|
|
51
|
-
/**
|
|
52
|
-
* When the node doesn't have the 'original' property, that means the codemod has been already applied,
|
|
53
|
-
* so we don't need to do any changes.
|
|
54
|
-
*/
|
|
55
|
-
if (!node.original) {
|
|
56
|
-
return node
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const newCallExpression = jscodeshift.callExpression(node.original.callee, [
|
|
60
|
-
jscodeshift.objectExpression([
|
|
61
|
-
jscodeshift.property(
|
|
62
|
-
'init',
|
|
63
|
-
jscodeshift.identifier('queries'),
|
|
64
|
-
node.original.arguments[0]
|
|
65
|
-
),
|
|
66
|
-
]),
|
|
67
|
-
])
|
|
68
|
-
|
|
69
|
-
// TODO: This should be part of one function!
|
|
70
|
-
if (node.typeParameters) {
|
|
71
|
-
newCallExpression.typeArguments = node.typeParameters
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return newCallExpression
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
transformer.execute(['useQueries'], replacer)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const transformUseQueryLikeUsages = ({
|
|
81
|
-
jscodeshift,
|
|
82
|
-
utils,
|
|
83
|
-
root,
|
|
84
|
-
filePath,
|
|
85
|
-
}) => {
|
|
86
|
-
const transformer = createUseQueryLikeTransformer({
|
|
87
|
-
jscodeshift,
|
|
88
|
-
utils,
|
|
89
|
-
root,
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
transformer.execute(
|
|
93
|
-
['useQuery', 'useInfiniteQuery', 'useIsFetching', 'useIsMutating'],
|
|
94
|
-
createKeyReplacer({
|
|
95
|
-
jscodeshift,
|
|
96
|
-
root,
|
|
97
|
-
filePath,
|
|
98
|
-
keyName: 'queryKey',
|
|
99
|
-
})
|
|
100
|
-
)
|
|
101
|
-
transformer.execute(
|
|
102
|
-
['useMutation'],
|
|
103
|
-
createKeyReplacer({
|
|
104
|
-
jscodeshift,
|
|
105
|
-
root,
|
|
106
|
-
filePath,
|
|
107
|
-
keyName: 'mutationKey',
|
|
108
|
-
})
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const transformQueryCacheUsages = ({ jscodeshift, utils, root, filePath }) => {
|
|
113
|
-
const transformer = createQueryCacheTransformer({ jscodeshift, utils, root })
|
|
114
|
-
const replacer = createKeyReplacer({ jscodeshift, root, filePath })
|
|
115
|
-
|
|
116
|
-
transformer.execute(replacer)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = (file, api) => {
|
|
120
|
-
const jscodeshift = api.jscodeshift
|
|
121
|
-
const root = jscodeshift(file.source)
|
|
122
|
-
|
|
123
|
-
// TODO: Execute the transformers only when it contains a `react-query` import!
|
|
124
|
-
|
|
125
|
-
const utils = createUtilsObject({ root, jscodeshift })
|
|
126
|
-
const filePath = file.path
|
|
127
|
-
|
|
128
|
-
// This function transforms usages like `useQuery` and `useMutation`.
|
|
129
|
-
transformUseQueryLikeUsages({ jscodeshift, utils, root, filePath })
|
|
130
|
-
// This function transforms usages of `useQueries`.
|
|
131
|
-
transformUseQueriesUsages({ jscodeshift, utils, root })
|
|
132
|
-
// This function transforms usages of `QueryClient`.
|
|
133
|
-
transformQueryClientUsages({ jscodeshift, utils, root, filePath })
|
|
134
|
-
// This function transforms usages of `QueryCache`.
|
|
135
|
-
transformQueryCacheUsages({ jscodeshift, utils, root, filePath })
|
|
136
|
-
|
|
137
|
-
return root.toSource({ quote: 'single' })
|
|
138
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module.exports = (file, api) => {
|
|
2
|
-
const jscodeshift = api.jscodeshift
|
|
3
|
-
const root = jscodeshift(file.source)
|
|
4
|
-
|
|
5
|
-
const replacements = [
|
|
6
|
-
{ from: 'react-query', to: '@tanstack/react-query' },
|
|
7
|
-
{ from: 'react-query/devtools', to: '@tanstack/react-query-devtools' },
|
|
8
|
-
]
|
|
9
|
-
|
|
10
|
-
replacements.forEach(({ from, to }) => {
|
|
11
|
-
root
|
|
12
|
-
.find(jscodeshift.ImportDeclaration, {
|
|
13
|
-
source: {
|
|
14
|
-
value: from,
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
.replaceWith(({ node }) => {
|
|
18
|
-
node.source.value = to
|
|
19
|
-
|
|
20
|
-
return node
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return root.toSource({ quote: 'single' })
|
|
25
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
module.exports = ({ root, jscodeshift }) => {
|
|
2
|
-
const findImportIdentifierOf = (importSpecifiers, identifier) => {
|
|
3
|
-
const specifier = importSpecifiers
|
|
4
|
-
.filter(node => node.value.imported.name === identifier)
|
|
5
|
-
.paths()
|
|
6
|
-
|
|
7
|
-
if (specifier.length > 0) {
|
|
8
|
-
return specifier[0].value.local
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return jscodeshift.identifier(identifier)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const findImportSpecifiers = () =>
|
|
15
|
-
root
|
|
16
|
-
.find(jscodeshift.ImportDeclaration, {
|
|
17
|
-
source: {
|
|
18
|
-
value: 'react-query',
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
.find(jscodeshift.ImportSpecifier, {})
|
|
22
|
-
|
|
23
|
-
const locateImports = identifiers => {
|
|
24
|
-
const findNamespaceImportIdentifier = () => {
|
|
25
|
-
const specifier = root
|
|
26
|
-
.find(jscodeshift.ImportDeclaration, {
|
|
27
|
-
source: {
|
|
28
|
-
value: 'react-query',
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
.find(jscodeshift.ImportNamespaceSpecifier)
|
|
32
|
-
.paths()
|
|
33
|
-
|
|
34
|
-
return specifier.length > 0 ? specifier[0].value.local : null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* First, we search for the namespace import identifier because if we have any, we assume the consumer uses
|
|
39
|
-
* namespace imports. In this case, we won't search for named imports at all.
|
|
40
|
-
*/
|
|
41
|
-
const namespaceImportIdentifier = findNamespaceImportIdentifier()
|
|
42
|
-
|
|
43
|
-
if (namespaceImportIdentifier) {
|
|
44
|
-
const identifierMap = {}
|
|
45
|
-
|
|
46
|
-
for (const identifier of identifiers) {
|
|
47
|
-
identifierMap[identifier] = jscodeshift.identifier(identifier)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
namespace: namespaceImportIdentifier,
|
|
52
|
-
...identifierMap,
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const importSpecifiers = findImportSpecifiers()
|
|
57
|
-
const identifierMap = {}
|
|
58
|
-
|
|
59
|
-
for (const identifier of identifiers) {
|
|
60
|
-
identifierMap[identifier] = findImportIdentifierOf(
|
|
61
|
-
importSpecifiers,
|
|
62
|
-
identifier
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
namespace: null,
|
|
68
|
-
...identifierMap,
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const findAllMethodCalls = () =>
|
|
73
|
-
root
|
|
74
|
-
// First, we need to find all method calls.
|
|
75
|
-
.find(jscodeshift.CallExpression, {
|
|
76
|
-
callee: {
|
|
77
|
-
type: jscodeshift.MemberExpression.name,
|
|
78
|
-
property: {
|
|
79
|
-
type: jscodeshift.Identifier.name,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
const findQueryClientIdentifiers = importIdentifiers =>
|
|
85
|
-
root
|
|
86
|
-
.find(jscodeshift.VariableDeclarator, {})
|
|
87
|
-
.filter(node => {
|
|
88
|
-
if (node.value.init) {
|
|
89
|
-
const initializer = node.value.init
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
isClassInstantiationOf(
|
|
93
|
-
initializer,
|
|
94
|
-
getSelectorByImports(importIdentifiers, 'QueryClient')
|
|
95
|
-
) ||
|
|
96
|
-
isFunctionCallOf(
|
|
97
|
-
initializer,
|
|
98
|
-
getSelectorByImports(importIdentifiers, 'useQueryClient')
|
|
99
|
-
)
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return false
|
|
104
|
-
})
|
|
105
|
-
.paths()
|
|
106
|
-
.map(node => node.value.id.name)
|
|
107
|
-
|
|
108
|
-
const isCallExpression = node =>
|
|
109
|
-
jscodeshift.match(node, { type: jscodeshift.CallExpression.name })
|
|
110
|
-
|
|
111
|
-
const isIdentifier = node =>
|
|
112
|
-
jscodeshift.match(node, { type: jscodeshift.Identifier.name })
|
|
113
|
-
|
|
114
|
-
const isMemberExpression = node =>
|
|
115
|
-
jscodeshift.match(node, { type: jscodeshift.MemberExpression.name })
|
|
116
|
-
|
|
117
|
-
const isNewExpression = node =>
|
|
118
|
-
jscodeshift.match(node, { type: jscodeshift.NewExpression.name })
|
|
119
|
-
|
|
120
|
-
const isClassInstantiationOf = (node, selector) => {
|
|
121
|
-
if (!isNewExpression(node)) {
|
|
122
|
-
return false
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const parts = selector.split('.')
|
|
126
|
-
|
|
127
|
-
return parts.length === 1
|
|
128
|
-
? isIdentifier(node.callee) && node.callee.name === parts[0]
|
|
129
|
-
: isMemberExpression(node.callee) &&
|
|
130
|
-
node.callee.object.name === parts[0] &&
|
|
131
|
-
node.callee.property.name === parts[1]
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const isFunctionCallOf = (node, selector) => {
|
|
135
|
-
if (!isCallExpression(node)) {
|
|
136
|
-
return false
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const parts = selector.split('.')
|
|
140
|
-
|
|
141
|
-
return parts.length === 1
|
|
142
|
-
? isIdentifier(node.callee) && node.callee.name === parts[0]
|
|
143
|
-
: isMemberExpression(node.callee) &&
|
|
144
|
-
node.callee.object.name === parts[0] &&
|
|
145
|
-
node.callee.property.name === parts[1]
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const getSelectorByImports = (imports, path) =>
|
|
149
|
-
imports.namespace
|
|
150
|
-
? `${imports.namespace.name}.${imports[path].name}`
|
|
151
|
-
: imports[path].name
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
findAllMethodCalls,
|
|
155
|
-
getSelectorByImports,
|
|
156
|
-
isCallExpression,
|
|
157
|
-
isClassInstantiationOf,
|
|
158
|
-
isFunctionCallOf,
|
|
159
|
-
isIdentifier,
|
|
160
|
-
isMemberExpression,
|
|
161
|
-
locateImports,
|
|
162
|
-
queryClient: {
|
|
163
|
-
findQueryClientIdentifiers,
|
|
164
|
-
},
|
|
165
|
-
}
|
|
166
|
-
}
|