@tanstack/vue-query 4.24.9 → 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/__mocks__/useBaseQuery.d.ts +2 -2
- package/build/lib/__mocks__/useQueryClient.d.ts +1 -1
- package/build/lib/devtools/devtools.esm.js +6 -12
- package/build/lib/devtools/devtools.esm.js.map +1 -1
- package/build/lib/devtools/devtools.js +6 -14
- package/build/lib/devtools/devtools.js.map +1 -1
- package/build/lib/devtools/devtools.mjs +6 -12
- package/build/lib/devtools/devtools.mjs.map +1 -1
- package/build/lib/devtools/utils.esm.js +0 -23
- package/build/lib/devtools/utils.esm.js.map +1 -1
- package/build/lib/devtools/utils.js +0 -25
- package/build/lib/devtools/utils.js.map +1 -1
- package/build/lib/devtools/utils.mjs +0 -23
- package/build/lib/devtools/utils.mjs.map +1 -1
- package/build/lib/index.js +0 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/mutationCache.d.ts +3 -3
- package/build/lib/mutationCache.esm.js +1 -3
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js +1 -5
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationCache.mjs +1 -3
- package/build/lib/mutationCache.mjs.map +1 -1
- package/build/lib/queryCache.d.ts +2 -4
- package/build/lib/queryCache.esm.js +5 -16
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js +4 -17
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryCache.mjs +5 -16
- package/build/lib/queryCache.mjs.map +1 -1
- package/build/lib/queryClient.d.ts +13 -29
- package/build/lib/queryClient.esm.js +33 -124
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +32 -125
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs +33 -124
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/types.d.ts +1 -13
- package/build/lib/useBaseQuery.d.ts +6 -7
- package/build/lib/useBaseQuery.esm.js +15 -41
- package/build/lib/useBaseQuery.esm.js.map +1 -1
- package/build/lib/useBaseQuery.js +12 -41
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.mjs +15 -41
- package/build/lib/useBaseQuery.mjs.map +1 -1
- package/build/lib/useInfiniteQuery.d.ts +10 -10
- package/build/lib/useInfiniteQuery.esm.js +5 -5
- package/build/lib/useInfiniteQuery.esm.js.map +1 -1
- package/build/lib/useInfiniteQuery.js +5 -7
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useInfiniteQuery.mjs +5 -5
- package/build/lib/useInfiniteQuery.mjs.map +1 -1
- package/build/lib/useIsFetching.d.ts +5 -6
- package/build/lib/useIsFetching.esm.js +10 -28
- package/build/lib/useIsFetching.esm.js.map +1 -1
- package/build/lib/useIsFetching.js +7 -28
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.mjs +10 -28
- package/build/lib/useIsFetching.mjs.map +1 -1
- package/build/lib/useIsMutating.d.ts +5 -6
- package/build/lib/useIsMutating.esm.js +10 -28
- package/build/lib/useIsMutating.esm.js.map +1 -1
- package/build/lib/useIsMutating.js +7 -28
- package/build/lib/useIsMutating.js.map +1 -1
- package/build/lib/useIsMutating.mjs +10 -28
- package/build/lib/useIsMutating.mjs.map +1 -1
- package/build/lib/useMutation.d.ts +6 -12
- package/build/lib/useMutation.esm.js +12 -41
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +9 -41
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +12 -41
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/useQueries.d.ts +15 -10
- package/build/lib/useQueries.esm.js +17 -26
- package/build/lib/useQueries.esm.js.map +1 -1
- package/build/lib/useQueries.js +16 -27
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.mjs +17 -26
- package/build/lib/useQueries.mjs.map +1 -1
- package/build/lib/useQuery.d.ts +14 -28
- package/build/lib/useQuery.esm.js +5 -5
- package/build/lib/useQuery.esm.js.map +1 -1
- package/build/lib/useQuery.js +5 -7
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/useQuery.mjs +5 -5
- package/build/lib/useQuery.mjs.map +1 -1
- package/build/lib/useQueryClient.esm.js +1 -7
- package/build/lib/useQueryClient.esm.js.map +1 -1
- package/build/lib/useQueryClient.js +1 -9
- package/build/lib/useQueryClient.js.map +1 -1
- package/build/lib/useQueryClient.mjs +1 -7
- package/build/lib/useQueryClient.mjs.map +1 -1
- package/build/lib/utils.d.ts +3 -6
- package/build/lib/utils.esm.js +9 -17
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +8 -20
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +9 -17
- package/build/lib/utils.mjs.map +1 -1
- package/build/lib/vueQueryPlugin.d.ts +0 -6
- package/build/lib/vueQueryPlugin.esm.js +9 -31
- package/build/lib/vueQueryPlugin.esm.js.map +1 -1
- package/build/lib/vueQueryPlugin.js +9 -33
- package/build/lib/vueQueryPlugin.js.map +1 -1
- package/build/lib/vueQueryPlugin.mjs +9 -31
- package/build/lib/vueQueryPlugin.mjs.map +1 -1
- package/build/umd/index.development.js +1033 -1858
- 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 +11 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","sources":["../../src/useQuery.ts"],"sourcesContent":["import type { ToRefs, UnwrapRef } from 'vue-demi'\nimport { QueryObserver } from '@tanstack/query-core'\nimport type {\n
|
|
1
|
+
{"version":3,"file":"useQuery.js","sources":["../../src/useQuery.ts"],"sourcesContent":["import type { ToRefs, UnwrapRef } from 'vue-demi'\nimport { QueryObserver } from '@tanstack/query-core'\nimport type {\n QueryKey,\n QueryObserverResult,\n DefinedQueryObserverResult,\n WithRequired,\n QueryObserverOptions,\n RegisteredError,\n} from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { DistributiveOmit, MaybeRefDeep } from './types'\nimport type { QueryClient } from './queryClient'\n\nexport type UseQueryOptions<\n TQueryFnData = unknown,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = {\n [Property in keyof QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >]: Property extends 'queryFn'\n ? QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n UnwrapRef<TQueryKey>\n >[Property]\n : MaybeRefDeep<\n WithRequired<\n QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n 'queryKey'\n >[Property]\n >\n}\n\nexport type UseQueryReturnType<TData, TError> = DistributiveOmit<\n UseBaseQueryReturnType<TData, TError>,\n 'refetch'\n> & {\n refetch: QueryObserverResult<TData, TError>['refetch']\n}\n\nexport type UseQueryDefinedReturnType<TData, TError> = DistributiveOmit<\n ToRefs<Readonly<DefinedQueryObserverResult<TData, TError>>>,\n 'refetch'\n> & {\n suspense: () => Promise<QueryObserverResult<TData, TError>>\n refetch: QueryObserverResult<TData, TError>['refetch']\n}\n\nexport function useQuery<\n TQueryFnData = unknown,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n > & {\n initialData?: undefined\n },\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData = unknown,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n > & {\n initialData: TQueryFnData | (() => TQueryFnData)\n },\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n const result = useBaseQuery(QueryObserver, options, queryClient)\n\n return {\n ...result,\n refetch: result.refetch.value,\n }\n}\n"],"names":["useQuery","options","queryClient","result","useBaseQuery","QueryObserver","refetch","value"],"mappings":";;;;;AAqGO,SAASA,QAAQ,CAMtBC,OAMC,EACDC,WAAyB,EAGkB;EAC3C,MAAMC,MAAM,GAAGC,yBAAY,CAACC,uBAAa,EAAEJ,OAAO,EAAEC,WAAW,CAAC,CAAA;EAEhE,OAAO;AACL,IAAA,GAAGC,MAAM;AACTG,IAAAA,OAAO,EAAEH,MAAM,CAACG,OAAO,CAACC,KAAAA;GACzB,CAAA;AACH;;;;"}
|
package/build/lib/useQuery.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { QueryObserver } from '@tanstack/query-core';
|
|
2
2
|
import { useBaseQuery } from './useBaseQuery.mjs';
|
|
3
3
|
|
|
4
|
-
function useQuery(
|
|
5
|
-
const result = useBaseQuery(QueryObserver,
|
|
6
|
-
return {
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
function useQuery(options, queryClient) {
|
|
5
|
+
const result = useBaseQuery(QueryObserver, options, queryClient);
|
|
6
|
+
return {
|
|
7
|
+
...result,
|
|
8
|
+
refetch: result.refetch.value
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.mjs","sources":["../../src/useQuery.ts"],"sourcesContent":["import type { ToRefs, UnwrapRef } from 'vue-demi'\nimport { QueryObserver } from '@tanstack/query-core'\nimport type {\n
|
|
1
|
+
{"version":3,"file":"useQuery.mjs","sources":["../../src/useQuery.ts"],"sourcesContent":["import type { ToRefs, UnwrapRef } from 'vue-demi'\nimport { QueryObserver } from '@tanstack/query-core'\nimport type {\n QueryKey,\n QueryObserverResult,\n DefinedQueryObserverResult,\n WithRequired,\n QueryObserverOptions,\n RegisteredError,\n} from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\nimport type { DistributiveOmit, MaybeRefDeep } from './types'\nimport type { QueryClient } from './queryClient'\n\nexport type UseQueryOptions<\n TQueryFnData = unknown,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = {\n [Property in keyof QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >]: Property extends 'queryFn'\n ? QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n UnwrapRef<TQueryKey>\n >[Property]\n : MaybeRefDeep<\n WithRequired<\n QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n 'queryKey'\n >[Property]\n >\n}\n\nexport type UseQueryReturnType<TData, TError> = DistributiveOmit<\n UseBaseQueryReturnType<TData, TError>,\n 'refetch'\n> & {\n refetch: QueryObserverResult<TData, TError>['refetch']\n}\n\nexport type UseQueryDefinedReturnType<TData, TError> = DistributiveOmit<\n ToRefs<Readonly<DefinedQueryObserverResult<TData, TError>>>,\n 'refetch'\n> & {\n suspense: () => Promise<QueryObserverResult<TData, TError>>\n refetch: QueryObserverResult<TData, TError>['refetch']\n}\n\nexport function useQuery<\n TQueryFnData = unknown,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n > & {\n initialData?: undefined\n },\n queryClient?: QueryClient,\n): UseQueryReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData = unknown,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n > & {\n initialData: TQueryFnData | (() => TQueryFnData)\n },\n queryClient?: QueryClient,\n): UseQueryDefinedReturnType<TData, TError>\n\nexport function useQuery<\n TQueryFnData,\n TError = RegisteredError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey\n >,\n queryClient?: QueryClient,\n):\n | UseQueryReturnType<TData, TError>\n | UseQueryDefinedReturnType<TData, TError> {\n const result = useBaseQuery(QueryObserver, options, queryClient)\n\n return {\n ...result,\n refetch: result.refetch.value,\n }\n}\n"],"names":["useQuery","options","queryClient","result","useBaseQuery","QueryObserver","refetch","value"],"mappings":";;;AAqGO,SAASA,QAAQ,CAMtBC,OAMC,EACDC,WAAyB,EAGkB;EAC3C,MAAMC,MAAM,GAAGC,YAAY,CAACC,aAAa,EAAEJ,OAAO,EAAEC,WAAW,CAAC,CAAA;EAEhE,OAAO;AACL,IAAA,GAAGC,MAAM;AACTG,IAAAA,OAAO,EAAEH,MAAM,CAACG,OAAO,CAACC,KAAAA;GACzB,CAAA;AACH;;;;"}
|
|
@@ -2,21 +2,15 @@ import { getCurrentInstance, inject } from 'vue-demi';
|
|
|
2
2
|
import { getClientKey } from './utils.esm.js';
|
|
3
3
|
|
|
4
4
|
function useQueryClient(id = '') {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const vm = (_getCurrentInstance = getCurrentInstance()) == null ? void 0 : _getCurrentInstance.proxy;
|
|
8
|
-
|
|
5
|
+
const vm = getCurrentInstance()?.proxy;
|
|
9
6
|
if (!vm) {
|
|
10
7
|
throw new Error('vue-query hooks can only be used inside setup() function.');
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
const key = getClientKey(id);
|
|
14
10
|
const queryClient = inject(key);
|
|
15
|
-
|
|
16
11
|
if (!queryClient) {
|
|
17
12
|
throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
|
|
18
13
|
}
|
|
19
|
-
|
|
20
14
|
return queryClient;
|
|
21
15
|
}
|
|
22
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.esm.js","sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { getCurrentInstance, inject } from 'vue-demi'\n\nimport type { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\n\nexport function useQueryClient(id = ''): QueryClient {\n const vm = getCurrentInstance()?.proxy\n\n if (!vm) {\n throw new Error('vue-query hooks can only be used inside setup() function.')\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"names":["useQueryClient","id","vm","getCurrentInstance","proxy","Error","key","getClientKey","queryClient","inject"],"mappings":";;;AAKO,SAASA,
|
|
1
|
+
{"version":3,"file":"useQueryClient.esm.js","sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { getCurrentInstance, inject } from 'vue-demi'\n\nimport type { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\n\nexport function useQueryClient(id = ''): QueryClient {\n const vm = getCurrentInstance()?.proxy\n\n if (!vm) {\n throw new Error('vue-query hooks can only be used inside setup() function.')\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"names":["useQueryClient","id","vm","getCurrentInstance","proxy","Error","key","getClientKey","queryClient","inject"],"mappings":";;;AAKO,SAASA,cAAc,CAACC,EAAE,GAAG,EAAE,EAAe;AACnD,EAAA,MAAMC,EAAE,GAAGC,kBAAkB,EAAE,EAAEC,KAAK,CAAA;EAEtC,IAAI,CAACF,EAAE,EAAE;AACP,IAAA,MAAM,IAAIG,KAAK,CAAC,2DAA2D,CAAC,CAAA;AAC9E,GAAA;AAEA,EAAA,MAAMC,GAAG,GAAGC,YAAY,CAACN,EAAE,CAAC,CAAA;AAC5B,EAAA,MAAMO,WAAW,GAAGC,MAAM,CAAcH,GAAG,CAAC,CAAA;EAE5C,IAAI,CAACE,WAAW,EAAE;AAChB,IAAA,MAAM,IAAIH,KAAK,CACb,iGAAiG,CAClG,CAAA;AACH,GAAA;AAEA,EAAA,OAAOG,WAAW,CAAA;AACpB;;;;"}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var vueDemi = require('vue-demi');
|
|
6
4
|
var utils = require('./utils.js');
|
|
7
5
|
|
|
8
6
|
function useQueryClient(id = '') {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const vm = (_getCurrentInstance = vueDemi.getCurrentInstance()) == null ? void 0 : _getCurrentInstance.proxy;
|
|
12
|
-
|
|
7
|
+
const vm = vueDemi.getCurrentInstance()?.proxy;
|
|
13
8
|
if (!vm) {
|
|
14
9
|
throw new Error('vue-query hooks can only be used inside setup() function.');
|
|
15
10
|
}
|
|
16
|
-
|
|
17
11
|
const key = utils.getClientKey(id);
|
|
18
12
|
const queryClient = vueDemi.inject(key);
|
|
19
|
-
|
|
20
13
|
if (!queryClient) {
|
|
21
14
|
throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
|
|
22
15
|
}
|
|
23
|
-
|
|
24
16
|
return queryClient;
|
|
25
17
|
}
|
|
26
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.js","sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { getCurrentInstance, inject } from 'vue-demi'\n\nimport type { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\n\nexport function useQueryClient(id = ''): QueryClient {\n const vm = getCurrentInstance()?.proxy\n\n if (!vm) {\n throw new Error('vue-query hooks can only be used inside setup() function.')\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"names":["useQueryClient","id","vm","getCurrentInstance","proxy","Error","key","getClientKey","queryClient","inject"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryClient.js","sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { getCurrentInstance, inject } from 'vue-demi'\n\nimport type { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\n\nexport function useQueryClient(id = ''): QueryClient {\n const vm = getCurrentInstance()?.proxy\n\n if (!vm) {\n throw new Error('vue-query hooks can only be used inside setup() function.')\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"names":["useQueryClient","id","vm","getCurrentInstance","proxy","Error","key","getClientKey","queryClient","inject"],"mappings":";;;;;AAKO,SAASA,cAAc,CAACC,EAAE,GAAG,EAAE,EAAe;AACnD,EAAA,MAAMC,EAAE,GAAGC,0BAAkB,EAAE,EAAEC,KAAK,CAAA;EAEtC,IAAI,CAACF,EAAE,EAAE;AACP,IAAA,MAAM,IAAIG,KAAK,CAAC,2DAA2D,CAAC,CAAA;AAC9E,GAAA;AAEA,EAAA,MAAMC,GAAG,GAAGC,kBAAY,CAACN,EAAE,CAAC,CAAA;AAC5B,EAAA,MAAMO,WAAW,GAAGC,cAAM,CAAcH,GAAG,CAAC,CAAA;EAE5C,IAAI,CAACE,WAAW,EAAE;AAChB,IAAA,MAAM,IAAIH,KAAK,CACb,iGAAiG,CAClG,CAAA;AACH,GAAA;AAEA,EAAA,OAAOG,WAAW,CAAA;AACpB;;;;"}
|
|
@@ -2,21 +2,15 @@ import { getCurrentInstance, inject } from 'vue-demi';
|
|
|
2
2
|
import { getClientKey } from './utils.mjs';
|
|
3
3
|
|
|
4
4
|
function useQueryClient(id = '') {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const vm = (_getCurrentInstance = getCurrentInstance()) == null ? void 0 : _getCurrentInstance.proxy;
|
|
8
|
-
|
|
5
|
+
const vm = getCurrentInstance()?.proxy;
|
|
9
6
|
if (!vm) {
|
|
10
7
|
throw new Error('vue-query hooks can only be used inside setup() function.');
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
const key = getClientKey(id);
|
|
14
10
|
const queryClient = inject(key);
|
|
15
|
-
|
|
16
11
|
if (!queryClient) {
|
|
17
12
|
throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");
|
|
18
13
|
}
|
|
19
|
-
|
|
20
14
|
return queryClient;
|
|
21
15
|
}
|
|
22
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.mjs","sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { getCurrentInstance, inject } from 'vue-demi'\n\nimport type { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\n\nexport function useQueryClient(id = ''): QueryClient {\n const vm = getCurrentInstance()?.proxy\n\n if (!vm) {\n throw new Error('vue-query hooks can only be used inside setup() function.')\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"names":["useQueryClient","id","vm","getCurrentInstance","proxy","Error","key","getClientKey","queryClient","inject"],"mappings":";;;AAKO,SAASA,
|
|
1
|
+
{"version":3,"file":"useQueryClient.mjs","sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { getCurrentInstance, inject } from 'vue-demi'\n\nimport type { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\n\nexport function useQueryClient(id = ''): QueryClient {\n const vm = getCurrentInstance()?.proxy\n\n if (!vm) {\n throw new Error('vue-query hooks can only be used inside setup() function.')\n }\n\n const key = getClientKey(id)\n const queryClient = inject<QueryClient>(key)\n\n if (!queryClient) {\n throw new Error(\n \"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.\",\n )\n }\n\n return queryClient\n}\n"],"names":["useQueryClient","id","vm","getCurrentInstance","proxy","Error","key","getClientKey","queryClient","inject"],"mappings":";;;AAKO,SAASA,cAAc,CAACC,EAAE,GAAG,EAAE,EAAe;AACnD,EAAA,MAAMC,EAAE,GAAGC,kBAAkB,EAAE,EAAEC,KAAK,CAAA;EAEtC,IAAI,CAACF,EAAE,EAAE;AACP,IAAA,MAAM,IAAIG,KAAK,CAAC,2DAA2D,CAAC,CAAA;AAC9E,GAAA;AAEA,EAAA,MAAMC,GAAG,GAAGC,YAAY,CAACN,EAAE,CAAC,CAAA;AAC5B,EAAA,MAAMO,WAAW,GAAGC,MAAM,CAAcH,GAAG,CAAC,CAAA;EAE5C,IAAI,CAACE,WAAW,EAAE;AAChB,IAAA,MAAM,IAAIH,KAAK,CACb,iGAAiG,CAClG,CAAA;AACH,GAAA;AAEA,EAAA,OAAOG,WAAW,CAAA;AACpB;;;;"}
|
package/build/lib/utils.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { UnwrapRef } from 'vue-demi';
|
|
1
|
+
import type { MaybeRefDeep } from './types';
|
|
3
2
|
export declare const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
4
3
|
export declare function getClientKey(key?: string): string;
|
|
5
|
-
export declare function isQueryKey(value: unknown): value is QueryKey;
|
|
6
|
-
export declare function isMutationKey(value: unknown): value is MutationKey;
|
|
7
4
|
export declare function updateState(state: Record<string, unknown>, update: Record<string, any>): void;
|
|
8
|
-
export declare function cloneDeep<T>(value: T
|
|
9
|
-
export declare function cloneDeepUnref<T>(obj: T):
|
|
5
|
+
export declare function cloneDeep<T>(value: MaybeRefDeep<T>, customizer?: (val: MaybeRefDeep<T>) => T | undefined): T;
|
|
6
|
+
export declare function cloneDeepUnref<T>(obj: MaybeRefDeep<T>): T;
|
package/build/lib/utils.esm.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { isRef, unref } from 'vue-demi';
|
|
2
2
|
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
3
|
const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT';
|
|
5
4
|
function getClientKey(key) {
|
|
6
|
-
const suffix = key ?
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
function isQueryKey(value) {
|
|
10
|
-
return Array.isArray(value);
|
|
11
|
-
}
|
|
12
|
-
function isMutationKey(value) {
|
|
13
|
-
return Array.isArray(value);
|
|
5
|
+
const suffix = key ? `:${key}` : '';
|
|
6
|
+
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
14
7
|
}
|
|
15
8
|
function updateState(state, update) {
|
|
16
9
|
Object.keys(state).forEach(key => {
|
|
@@ -20,21 +13,21 @@ function updateState(state, update) {
|
|
|
20
13
|
function cloneDeep(value, customizer) {
|
|
21
14
|
if (customizer) {
|
|
22
15
|
const result = customizer(value);
|
|
23
|
-
|
|
24
|
-
if (result
|
|
16
|
+
// If it's a ref of undefined, return undefined
|
|
17
|
+
if (result === undefined && isRef(value)) {
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
if (result !== undefined) {
|
|
25
21
|
return result;
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
if (Array.isArray(value)) {
|
|
30
25
|
return value.map(val => cloneDeep(val, customizer));
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
if (typeof value === 'object' && isPlainObject(value)) {
|
|
34
28
|
const entries = Object.entries(value).map(([key, val]) => [key, cloneDeep(val, customizer)]);
|
|
35
29
|
return Object.fromEntries(entries);
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
return value;
|
|
39
32
|
}
|
|
40
33
|
function cloneDeepUnref(obj) {
|
|
@@ -42,17 +35,16 @@ function cloneDeepUnref(obj) {
|
|
|
42
35
|
if (isRef(val)) {
|
|
43
36
|
return cloneDeepUnref(unref(val));
|
|
44
37
|
}
|
|
38
|
+
return undefined;
|
|
45
39
|
});
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
function isPlainObject(value) {
|
|
49
42
|
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
50
43
|
return false;
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
const prototype = Object.getPrototypeOf(value);
|
|
54
46
|
return prototype === null || prototype === Object.prototype;
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey,
|
|
49
|
+
export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, updateState };
|
|
58
50
|
//# sourceMappingURL=utils.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.esm.js","sources":["../../src/utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"utils.esm.js","sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, unknown>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customizer?: (val: MaybeRefDeep<T>) => T | undefined,\n): T {\n if (customizer) {\n const result = customizer(value)\n // If it's a ref of undefined, return undefined\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val) => cloneDeep(val, customizer)) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n cloneDeep(val, customizer),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeepUnref<T>(obj: MaybeRefDeep<T>): T {\n return cloneDeep(obj, (val) => {\n if (isRef(val)) {\n return cloneDeepUnref(unref(val))\n }\n\n return undefined\n })\n}\n\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n"],"names":["VUE_QUERY_CLIENT","getClientKey","key","suffix","updateState","state","update","Object","keys","forEach","cloneDeep","value","customizer","result","undefined","isRef","Array","isArray","map","val","isPlainObject","entries","fromEntries","cloneDeepUnref","obj","unref","prototype","toString","call","getPrototypeOf"],"mappings":";;AAGO,MAAMA,gBAAgB,GAAG,mBAAkB;AAE3C,SAASC,YAAY,CAACC,GAAY,EAAE;EACzC,MAAMC,MAAM,GAAGD,GAAG,GAAI,IAAGA,GAAI,CAAA,CAAC,GAAG,EAAE,CAAA;AACnC,EAAA,OAAQ,CAAEF,EAAAA,gBAAiB,CAAEG,EAAAA,MAAO,CAAC,CAAA,CAAA;AACvC,CAAA;AAEO,SAASC,WAAW,CACzBC,KAA8B,EAC9BC,MAA2B,EACrB;EACNC,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAACI,OAAO,CAAEP,GAAG,IAAK;AAClCG,IAAAA,KAAK,CAACH,GAAG,CAAC,GAAGI,MAAM,CAACJ,GAAG,CAAC,CAAA;AAC1B,GAAC,CAAC,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;AACJ,CAAA;AAEA,SAASM,aAAa,CAACT,KAAc,EAAmB;AACtD,EAAA,IAAIJ,MAAM,CAACmB,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACjB,KAAK,CAAC,KAAK,iBAAiB,EAAE;AAC/D,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,MAAMe,SAAS,GAAGnB,MAAM,CAACsB,cAAc,CAAClB,KAAK,CAAC,CAAA;EAC9C,OAAOe,SAAS,KAAK,IAAI,IAAIA,SAAS,KAAKnB,MAAM,CAACmB,SAAS,CAAA;AAC7D;;;;"}
|
package/build/lib/utils.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var vueDemi = require('vue-demi');
|
|
6
4
|
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
5
|
const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT';
|
|
9
6
|
function getClientKey(key) {
|
|
10
|
-
const suffix = key ?
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
function isQueryKey(value) {
|
|
14
|
-
return Array.isArray(value);
|
|
15
|
-
}
|
|
16
|
-
function isMutationKey(value) {
|
|
17
|
-
return Array.isArray(value);
|
|
7
|
+
const suffix = key ? `:${key}` : '';
|
|
8
|
+
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
18
9
|
}
|
|
19
10
|
function updateState(state, update) {
|
|
20
11
|
Object.keys(state).forEach(key => {
|
|
@@ -24,21 +15,21 @@ function updateState(state, update) {
|
|
|
24
15
|
function cloneDeep(value, customizer) {
|
|
25
16
|
if (customizer) {
|
|
26
17
|
const result = customizer(value);
|
|
27
|
-
|
|
28
|
-
if (result
|
|
18
|
+
// If it's a ref of undefined, return undefined
|
|
19
|
+
if (result === undefined && vueDemi.isRef(value)) {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
if (result !== undefined) {
|
|
29
23
|
return result;
|
|
30
24
|
}
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
if (Array.isArray(value)) {
|
|
34
27
|
return value.map(val => cloneDeep(val, customizer));
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
if (typeof value === 'object' && isPlainObject(value)) {
|
|
38
30
|
const entries = Object.entries(value).map(([key, val]) => [key, cloneDeep(val, customizer)]);
|
|
39
31
|
return Object.fromEntries(entries);
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
return value;
|
|
43
34
|
}
|
|
44
35
|
function cloneDeepUnref(obj) {
|
|
@@ -46,14 +37,13 @@ function cloneDeepUnref(obj) {
|
|
|
46
37
|
if (vueDemi.isRef(val)) {
|
|
47
38
|
return cloneDeepUnref(vueDemi.unref(val));
|
|
48
39
|
}
|
|
40
|
+
return undefined;
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
function isPlainObject(value) {
|
|
53
44
|
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
54
45
|
return false;
|
|
55
46
|
}
|
|
56
|
-
|
|
57
47
|
const prototype = Object.getPrototypeOf(value);
|
|
58
48
|
return prototype === null || prototype === Object.prototype;
|
|
59
49
|
}
|
|
@@ -62,7 +52,5 @@ exports.VUE_QUERY_CLIENT = VUE_QUERY_CLIENT;
|
|
|
62
52
|
exports.cloneDeep = cloneDeep;
|
|
63
53
|
exports.cloneDeepUnref = cloneDeepUnref;
|
|
64
54
|
exports.getClientKey = getClientKey;
|
|
65
|
-
exports.isMutationKey = isMutationKey;
|
|
66
|
-
exports.isQueryKey = isQueryKey;
|
|
67
55
|
exports.updateState = updateState;
|
|
68
56
|
//# sourceMappingURL=utils.js.map
|
package/build/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, unknown>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customizer?: (val: MaybeRefDeep<T>) => T | undefined,\n): T {\n if (customizer) {\n const result = customizer(value)\n // If it's a ref of undefined, return undefined\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val) => cloneDeep(val, customizer)) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n cloneDeep(val, customizer),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeepUnref<T>(obj: MaybeRefDeep<T>): T {\n return cloneDeep(obj, (val) => {\n if (isRef(val)) {\n return cloneDeepUnref(unref(val))\n }\n\n return undefined\n })\n}\n\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n"],"names":["VUE_QUERY_CLIENT","getClientKey","key","suffix","updateState","state","update","Object","keys","forEach","cloneDeep","value","customizer","result","undefined","isRef","Array","isArray","map","val","isPlainObject","entries","fromEntries","cloneDeepUnref","obj","unref","prototype","toString","call","getPrototypeOf"],"mappings":";;;;AAGO,MAAMA,gBAAgB,GAAG,mBAAkB;AAE3C,SAASC,YAAY,CAACC,GAAY,EAAE;EACzC,MAAMC,MAAM,GAAGD,GAAG,GAAI,IAAGA,GAAI,CAAA,CAAC,GAAG,EA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AAA;AAEA,EAAA,OAAOV,KAAK,CAAA;AACd,CAAA;AAEO,SAASY,cAAc,CAAIC,GAAoB,EAAK;AACzD,EAAA,OAAOd,SAAS,CAACc,GAAG,EAAGL,GAAG,IAAK;AAC7B,IAAA,IAAIJ,aAAK,CAACI,GAAG,CAAC,EAAE;AACd,MAAA,OAAOI,cAAc,CAACE,aAAK,CAACN,GAAG,CAAC,CAAC,CAAA;AACnC,KAAA;AAEA,IAAA,OAAOL,SAAS,CAAA;AAClB,GAAC,CAAC,CAAA;AACJ,CAAA;AAEA,SAASM,aAAa,CAACT,KAAc,EAAmB;AACtD,EAAA,IAAIJ,MAAM,CAACmB,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACjB,KAAK,CAAC,KAAK,iBAAiB,EAAE;AAC/D,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,MAAMe,SAAS,GAAGnB,MAAM,CAACsB,cAAc,CAAClB,KAAK,CAAC,CAAA;EAC9C,OAAOe,SAAS,KAAK,IAAI,IAAIA,SAAS,KAAKnB,MAAM,CAACmB,SAAS,CAAA;AAC7D;;;;;;;;"}
|
package/build/lib/utils.mjs
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { isRef, unref } from 'vue-demi';
|
|
2
2
|
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
3
|
const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT';
|
|
5
4
|
function getClientKey(key) {
|
|
6
|
-
const suffix = key ?
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
function isQueryKey(value) {
|
|
10
|
-
return Array.isArray(value);
|
|
11
|
-
}
|
|
12
|
-
function isMutationKey(value) {
|
|
13
|
-
return Array.isArray(value);
|
|
5
|
+
const suffix = key ? `:${key}` : '';
|
|
6
|
+
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
14
7
|
}
|
|
15
8
|
function updateState(state, update) {
|
|
16
9
|
Object.keys(state).forEach(key => {
|
|
@@ -20,21 +13,21 @@ function updateState(state, update) {
|
|
|
20
13
|
function cloneDeep(value, customizer) {
|
|
21
14
|
if (customizer) {
|
|
22
15
|
const result = customizer(value);
|
|
23
|
-
|
|
24
|
-
if (result
|
|
16
|
+
// If it's a ref of undefined, return undefined
|
|
17
|
+
if (result === undefined && isRef(value)) {
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
if (result !== undefined) {
|
|
25
21
|
return result;
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
if (Array.isArray(value)) {
|
|
30
25
|
return value.map(val => cloneDeep(val, customizer));
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
if (typeof value === 'object' && isPlainObject(value)) {
|
|
34
28
|
const entries = Object.entries(value).map(([key, val]) => [key, cloneDeep(val, customizer)]);
|
|
35
29
|
return Object.fromEntries(entries);
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
return value;
|
|
39
32
|
}
|
|
40
33
|
function cloneDeepUnref(obj) {
|
|
@@ -42,17 +35,16 @@ function cloneDeepUnref(obj) {
|
|
|
42
35
|
if (isRef(val)) {
|
|
43
36
|
return cloneDeepUnref(unref(val));
|
|
44
37
|
}
|
|
38
|
+
return undefined;
|
|
45
39
|
});
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
function isPlainObject(value) {
|
|
49
42
|
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
50
43
|
return false;
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
const prototype = Object.getPrototypeOf(value);
|
|
54
46
|
return prototype === null || prototype === Object.prototype;
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey,
|
|
49
|
+
export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, updateState };
|
|
58
50
|
//# sourceMappingURL=utils.mjs.map
|
package/build/lib/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\nexport function updateState(\n state: Record<string, unknown>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customizer?: (val: MaybeRefDeep<T>) => T | undefined,\n): T {\n if (customizer) {\n const result = customizer(value)\n // If it's a ref of undefined, return undefined\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val) => cloneDeep(val, customizer)) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n cloneDeep(val, customizer),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeepUnref<T>(obj: MaybeRefDeep<T>): T {\n return cloneDeep(obj, (val) => {\n if (isRef(val)) {\n return cloneDeepUnref(unref(val))\n }\n\n return undefined\n })\n}\n\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n"],"names":["VUE_QUERY_CLIENT","getClientKey","key","suffix","updateState","state","update","Object","keys","forEach","cloneDeep","value","customizer","result","undefined","isRef","Array","isArray","map","val","isPlainObject","entries","fromEntries","cloneDeepUnref","obj","unref","prototype","toString","call","getPrototypeOf"],"mappings":";;AAGO,MAAMA,gBAAgB,GAAG,mBAAkB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AAG,EAAEP,UAAU,CAAC,CAC3B,CAAC,CAAA;AACF,IAAA,OAAOL,MAAM,CAACe,WAAW,CAACD,OAAO,CAAC,CAAA;AACpC,GAAA;AAEA,EAAA,OAAOV,KAAK,CAAA;AACd,CAAA;AAEO,SAASY,cAAc,CAAIC,GAAoB,EAAK;AACzD,EAAA,OAAOd,SAAS,CAACc,GAAG,EAAGL,GAAG,IAAK;AAC7B,IAAA,IAAIJ,KAAK,CAACI,GAAG,CAAC,EAAE;AACd,MAAA,OAAOI,cAAc,CAACE,KAAK,CAACN,GAAG,CAAC,CAAC,CAAA;AACnC,KAAA;AAEA,IAAA,OAAOL,SAAS,CAAA;AAClB,GAAC,CAAC,CAAA;AACJ,CAAA;AAEA,SAASM,aAAa,CAACT,KAAc,EAAmB;AACtD,EAAA,IAAIJ,MAAM,CAACmB,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACjB,KAAK,CAAC,KAAK,iBAAiB,EAAE;AAC/D,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,MAAMe,SAAS,GAAGnB,MAAM,CAACsB,cAAc,CAAClB,KAAK,CAAC,CAAA;EAC9C,OAAOe,SAAS,KAAK,IAAI,IAAIA,SAAS,KAAKnB,MAAM,CAACmB,SAAS,CAAA;AAC7D;;;;"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import type { QueryClientConfig } from '@tanstack/query-core';
|
|
2
2
|
import { QueryClient } from './queryClient';
|
|
3
3
|
import type { MaybeRefDeep } from './types';
|
|
4
|
-
declare global {
|
|
5
|
-
interface Window {
|
|
6
|
-
__VUE_QUERY_CONTEXT__?: QueryClient;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
4
|
declare type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
10
5
|
interface CommonOptions {
|
|
11
6
|
queryClientKey?: string;
|
|
12
|
-
contextSharing?: boolean;
|
|
13
7
|
clientPersister?: ClientPersister;
|
|
14
8
|
}
|
|
15
9
|
interface ConfigOptions extends CommonOptions {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isVue2 } from 'vue-demi';
|
|
2
|
+
import { isServer } from '@tanstack/query-core';
|
|
2
3
|
import { QueryClient } from './queryClient.esm.js';
|
|
3
4
|
import { getClientKey } from './utils.esm.js';
|
|
4
5
|
import { setupDevtools } from './devtools/devtools.esm.js';
|
|
@@ -7,29 +8,18 @@ const VueQueryPlugin = {
|
|
|
7
8
|
install: (app, options = {}) => {
|
|
8
9
|
const clientKey = getClientKey(options.queryClientKey);
|
|
9
10
|
let client;
|
|
10
|
-
|
|
11
11
|
if ('queryClient' in options && options.queryClient) {
|
|
12
12
|
client = options.queryClient;
|
|
13
13
|
} else {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
17
|
-
client = new QueryClient(clientConfig);
|
|
18
|
-
window.__VUE_QUERY_CONTEXT__ = client;
|
|
19
|
-
} else {
|
|
20
|
-
client = window.__VUE_QUERY_CONTEXT__;
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
24
|
-
client = new QueryClient(clientConfig);
|
|
25
|
-
}
|
|
14
|
+
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
15
|
+
client = new QueryClient(clientConfig);
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let persisterUnmount = () => {
|
|
17
|
+
if (!isServer) {
|
|
18
|
+
client.mount();
|
|
19
|
+
}
|
|
20
|
+
let persisterUnmount = () => {
|
|
21
|
+
// noop
|
|
31
22
|
};
|
|
32
|
-
|
|
33
23
|
if (options.clientPersister) {
|
|
34
24
|
client.isRestoring.value = true;
|
|
35
25
|
const [unmount, promise] = options.clientPersister(client);
|
|
@@ -38,29 +28,21 @@ const VueQueryPlugin = {
|
|
|
38
28
|
client.isRestoring.value = false;
|
|
39
29
|
});
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
43
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
31
|
const cleanup = () => {
|
|
47
32
|
client.unmount();
|
|
48
33
|
persisterUnmount();
|
|
49
34
|
};
|
|
50
|
-
|
|
51
35
|
if (app.onUnmount) {
|
|
52
36
|
app.onUnmount(cleanup);
|
|
53
37
|
} else {
|
|
54
38
|
const originalUnmount = app.unmount;
|
|
55
|
-
|
|
56
39
|
app.unmount = function vueQueryUnmount() {
|
|
57
40
|
cleanup();
|
|
58
41
|
originalUnmount();
|
|
59
42
|
};
|
|
60
43
|
}
|
|
61
|
-
/* istanbul ignore next */
|
|
62
|
-
|
|
63
44
|
|
|
45
|
+
/* istanbul ignore next */
|
|
64
46
|
if (isVue2) {
|
|
65
47
|
app.mixin({
|
|
66
48
|
beforeCreate() {
|
|
@@ -72,20 +54,16 @@ const VueQueryPlugin = {
|
|
|
72
54
|
set: v => Object.assign(provideCache, v)
|
|
73
55
|
});
|
|
74
56
|
}
|
|
75
|
-
|
|
76
57
|
this._provided[clientKey] = client;
|
|
77
|
-
|
|
78
58
|
if (process.env.NODE_ENV === 'development') {
|
|
79
59
|
if (this === this.$root) {
|
|
80
60
|
setupDevtools(this, client);
|
|
81
61
|
}
|
|
82
62
|
}
|
|
83
63
|
}
|
|
84
|
-
|
|
85
64
|
});
|
|
86
65
|
} else {
|
|
87
66
|
app.provide(clientKey, client);
|
|
88
|
-
|
|
89
67
|
if (process.env.NODE_ENV === 'development') {
|
|
90
68
|
setupDevtools(app, client);
|
|
91
69
|
}
|