@tanstack/vue-query 5.94.4 → 5.95.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/legacy/_tsup-dts-rollup.d.cts +855 -0
- package/build/legacy/_tsup-dts-rollup.d.ts +855 -0
- package/build/legacy/devtools/devtools.cjs +258 -0
- package/build/legacy/devtools/devtools.cjs.map +1 -0
- package/build/legacy/devtools/devtools.d.cts +1 -0
- package/build/legacy/devtools/devtools.d.ts +1 -0
- package/build/legacy/devtools/devtools.js +238 -0
- package/build/legacy/devtools/devtools.js.map +1 -0
- package/build/legacy/devtools/utils.cjs +105 -0
- package/build/legacy/devtools/utils.cjs.map +1 -0
- package/build/legacy/devtools/utils.d.cts +5 -0
- package/build/legacy/devtools/utils.d.ts +5 -0
- package/build/legacy/devtools/utils.js +76 -0
- package/build/legacy/devtools/utils.js.map +1 -0
- package/build/legacy/index.cjs +75 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +169 -0
- package/build/legacy/index.d.ts +169 -0
- package/build/legacy/index.js +34 -0
- package/build/legacy/index.js.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs +33 -0
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -0
- package/build/legacy/infiniteQueryOptions.d.cts +3 -0
- package/build/legacy/infiniteQueryOptions.d.ts +3 -0
- package/build/legacy/infiniteQueryOptions.js +8 -0
- package/build/legacy/infiniteQueryOptions.js.map +1 -0
- package/build/legacy/mutationCache.cjs +40 -0
- package/build/legacy/mutationCache.cjs.map +1 -0
- package/build/legacy/mutationCache.d.cts +1 -0
- package/build/legacy/mutationCache.d.ts +1 -0
- package/build/legacy/mutationCache.js +15 -0
- package/build/legacy/mutationCache.js.map +1 -0
- package/build/legacy/queryCache.cjs +40 -0
- package/build/legacy/queryCache.cjs.map +1 -0
- package/build/legacy/queryCache.d.cts +1 -0
- package/build/legacy/queryCache.d.ts +1 -0
- package/build/legacy/queryCache.js +15 -0
- package/build/legacy/queryCache.js.map +1 -0
- package/build/legacy/queryClient.cjs +141 -0
- package/build/legacy/queryClient.cjs.map +1 -0
- package/build/legacy/queryClient.d.cts +1 -0
- package/build/legacy/queryClient.d.ts +1 -0
- package/build/legacy/queryClient.js +116 -0
- package/build/legacy/queryClient.js.map +1 -0
- package/build/legacy/queryOptions.cjs +33 -0
- package/build/legacy/queryOptions.cjs.map +1 -0
- package/build/legacy/queryOptions.d.cts +1 -0
- package/build/legacy/queryOptions.d.ts +1 -0
- package/build/legacy/queryOptions.js +8 -0
- package/build/legacy/queryOptions.js.map +1 -0
- package/build/legacy/types.cjs +19 -0
- package/build/legacy/types.cjs.map +1 -0
- package/build/legacy/types.d.cts +9 -0
- package/build/legacy/types.d.ts +9 -0
- package/build/legacy/types.js +1 -0
- package/build/legacy/types.js.map +1 -0
- package/build/legacy/useBaseQuery.cjs +143 -0
- package/build/legacy/useBaseQuery.cjs.map +1 -0
- package/build/legacy/useBaseQuery.d.cts +2 -0
- package/build/legacy/useBaseQuery.d.ts +2 -0
- package/build/legacy/useBaseQuery.js +128 -0
- package/build/legacy/useBaseQuery.js.map +1 -0
- package/build/legacy/useInfiniteQuery.cjs +39 -0
- package/build/legacy/useInfiniteQuery.cjs.map +1 -0
- package/build/legacy/useInfiniteQuery.d.cts +3 -0
- package/build/legacy/useInfiniteQuery.d.ts +3 -0
- package/build/legacy/useInfiniteQuery.js +14 -0
- package/build/legacy/useInfiniteQuery.js.map +1 -0
- package/build/legacy/useIsFetching.cjs +54 -0
- package/build/legacy/useIsFetching.cjs.map +1 -0
- package/build/legacy/useIsFetching.d.cts +2 -0
- package/build/legacy/useIsFetching.d.ts +2 -0
- package/build/legacy/useIsFetching.js +29 -0
- package/build/legacy/useIsFetching.js.map +1 -0
- package/build/legacy/useMutation.cjs +79 -0
- package/build/legacy/useMutation.cjs.map +1 -0
- package/build/legacy/useMutation.d.cts +3 -0
- package/build/legacy/useMutation.d.ts +3 -0
- package/build/legacy/useMutation.js +64 -0
- package/build/legacy/useMutation.js.map +1 -0
- package/build/legacy/useMutationState.cjs +82 -0
- package/build/legacy/useMutationState.cjs.map +1 -0
- package/build/legacy/useMutationState.d.cts +4 -0
- package/build/legacy/useMutationState.d.ts +4 -0
- package/build/legacy/useMutationState.js +63 -0
- package/build/legacy/useMutationState.js.map +1 -0
- package/build/legacy/useQueries.cjs +115 -0
- package/build/legacy/useQueries.cjs.map +1 -0
- package/build/legacy/useQueries.d.cts +3 -0
- package/build/legacy/useQueries.d.ts +3 -0
- package/build/legacy/useQueries.js +99 -0
- package/build/legacy/useQueries.js.map +1 -0
- package/build/legacy/useQuery.cjs +35 -0
- package/build/legacy/useQuery.cjs.map +1 -0
- package/build/legacy/useQuery.d.cts +6 -0
- package/build/legacy/useQuery.d.ts +6 -0
- package/build/legacy/useQuery.js +10 -0
- package/build/legacy/useQuery.js.map +1 -0
- package/build/legacy/useQueryClient.cjs +47 -0
- package/build/legacy/useQueryClient.cjs.map +1 -0
- package/build/legacy/useQueryClient.d.cts +1 -0
- package/build/legacy/useQueryClient.d.ts +1 -0
- package/build/legacy/useQueryClient.js +22 -0
- package/build/legacy/useQueryClient.js.map +1 -0
- package/build/legacy/utils.cjs +100 -0
- package/build/legacy/utils.cjs.map +1 -0
- package/build/legacy/utils.d.cts +5 -0
- package/build/legacy/utils.d.ts +5 -0
- package/build/legacy/utils.js +71 -0
- package/build/legacy/utils.js.map +1 -0
- package/build/legacy/vueQueryPlugin.cjs +105 -0
- package/build/legacy/vueQueryPlugin.cjs.map +1 -0
- package/build/legacy/vueQueryPlugin.d.cts +2 -0
- package/build/legacy/vueQueryPlugin.d.ts +2 -0
- package/build/legacy/vueQueryPlugin.js +80 -0
- package/build/legacy/vueQueryPlugin.js.map +1 -0
- package/build/modern/_tsup-dts-rollup.d.cts +855 -0
- package/build/modern/_tsup-dts-rollup.d.ts +855 -0
- package/build/modern/devtools/devtools.cjs +256 -0
- package/build/modern/devtools/devtools.cjs.map +1 -0
- package/build/modern/devtools/devtools.d.cts +1 -0
- package/build/modern/devtools/devtools.d.ts +1 -0
- package/build/modern/devtools/devtools.js +236 -0
- package/build/modern/devtools/devtools.js.map +1 -0
- package/build/modern/devtools/utils.cjs +105 -0
- package/build/modern/devtools/utils.cjs.map +1 -0
- package/build/modern/devtools/utils.d.cts +5 -0
- package/build/modern/devtools/utils.d.ts +5 -0
- package/build/modern/devtools/utils.js +76 -0
- package/build/modern/devtools/utils.js.map +1 -0
- package/build/modern/index.cjs +75 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +169 -0
- package/build/modern/index.d.ts +169 -0
- package/build/modern/index.js +34 -0
- package/build/modern/index.js.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs +33 -0
- package/build/modern/infiniteQueryOptions.cjs.map +1 -0
- package/build/modern/infiniteQueryOptions.d.cts +3 -0
- package/build/modern/infiniteQueryOptions.d.ts +3 -0
- package/build/modern/infiniteQueryOptions.js +8 -0
- package/build/modern/infiniteQueryOptions.js.map +1 -0
- package/build/modern/mutationCache.cjs +40 -0
- package/build/modern/mutationCache.cjs.map +1 -0
- package/build/modern/mutationCache.d.cts +1 -0
- package/build/modern/mutationCache.d.ts +1 -0
- package/build/modern/mutationCache.js +15 -0
- package/build/modern/mutationCache.js.map +1 -0
- package/build/modern/queryCache.cjs +40 -0
- package/build/modern/queryCache.cjs.map +1 -0
- package/build/modern/queryCache.d.cts +1 -0
- package/build/modern/queryCache.d.ts +1 -0
- package/build/modern/queryCache.js +15 -0
- package/build/modern/queryCache.js.map +1 -0
- package/build/modern/queryClient.cjs +141 -0
- package/build/modern/queryClient.cjs.map +1 -0
- package/build/modern/queryClient.d.cts +1 -0
- package/build/modern/queryClient.d.ts +1 -0
- package/build/modern/queryClient.js +116 -0
- package/build/modern/queryClient.js.map +1 -0
- package/build/modern/queryOptions.cjs +33 -0
- package/build/modern/queryOptions.cjs.map +1 -0
- package/build/modern/queryOptions.d.cts +1 -0
- package/build/modern/queryOptions.d.ts +1 -0
- package/build/modern/queryOptions.js +8 -0
- package/build/modern/queryOptions.js.map +1 -0
- package/build/modern/types.cjs +19 -0
- package/build/modern/types.cjs.map +1 -0
- package/build/modern/types.d.cts +9 -0
- package/build/modern/types.d.ts +9 -0
- package/build/modern/types.js +1 -0
- package/build/modern/types.js.map +1 -0
- package/build/modern/useBaseQuery.cjs +142 -0
- package/build/modern/useBaseQuery.cjs.map +1 -0
- package/build/modern/useBaseQuery.d.cts +2 -0
- package/build/modern/useBaseQuery.d.ts +2 -0
- package/build/modern/useBaseQuery.js +127 -0
- package/build/modern/useBaseQuery.js.map +1 -0
- package/build/modern/useInfiniteQuery.cjs +39 -0
- package/build/modern/useInfiniteQuery.cjs.map +1 -0
- package/build/modern/useInfiniteQuery.d.cts +3 -0
- package/build/modern/useInfiniteQuery.d.ts +3 -0
- package/build/modern/useInfiniteQuery.js +14 -0
- package/build/modern/useInfiniteQuery.js.map +1 -0
- package/build/modern/useIsFetching.cjs +54 -0
- package/build/modern/useIsFetching.cjs.map +1 -0
- package/build/modern/useIsFetching.d.cts +2 -0
- package/build/modern/useIsFetching.d.ts +2 -0
- package/build/modern/useIsFetching.js +29 -0
- package/build/modern/useIsFetching.js.map +1 -0
- package/build/modern/useMutation.cjs +79 -0
- package/build/modern/useMutation.cjs.map +1 -0
- package/build/modern/useMutation.d.cts +3 -0
- package/build/modern/useMutation.d.ts +3 -0
- package/build/modern/useMutation.js +64 -0
- package/build/modern/useMutation.js.map +1 -0
- package/build/modern/useMutationState.cjs +82 -0
- package/build/modern/useMutationState.cjs.map +1 -0
- package/build/modern/useMutationState.d.cts +4 -0
- package/build/modern/useMutationState.d.ts +4 -0
- package/build/modern/useMutationState.js +63 -0
- package/build/modern/useMutationState.js.map +1 -0
- package/build/modern/useQueries.cjs +114 -0
- package/build/modern/useQueries.cjs.map +1 -0
- package/build/modern/useQueries.d.cts +3 -0
- package/build/modern/useQueries.d.ts +3 -0
- package/build/modern/useQueries.js +98 -0
- package/build/modern/useQueries.js.map +1 -0
- package/build/modern/useQuery.cjs +35 -0
- package/build/modern/useQuery.cjs.map +1 -0
- package/build/modern/useQuery.d.cts +6 -0
- package/build/modern/useQuery.d.ts +6 -0
- package/build/modern/useQuery.js +10 -0
- package/build/modern/useQuery.js.map +1 -0
- package/build/modern/useQueryClient.cjs +47 -0
- package/build/modern/useQueryClient.cjs.map +1 -0
- package/build/modern/useQueryClient.d.cts +1 -0
- package/build/modern/useQueryClient.d.ts +1 -0
- package/build/modern/useQueryClient.js +22 -0
- package/build/modern/useQueryClient.js.map +1 -0
- package/build/modern/utils.cjs +100 -0
- package/build/modern/utils.cjs.map +1 -0
- package/build/modern/utils.d.cts +5 -0
- package/build/modern/utils.d.ts +5 -0
- package/build/modern/utils.js +71 -0
- package/build/modern/utils.js.map +1 -0
- package/build/modern/vueQueryPlugin.cjs +104 -0
- package/build/modern/vueQueryPlugin.cjs.map +1 -0
- package/build/modern/vueQueryPlugin.d.cts +2 -0
- package/build/modern/vueQueryPlugin.d.ts +2 -0
- package/build/modern/vueQueryPlugin.js +79 -0
- package/build/modern/vueQueryPlugin.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/useQueryClient.ts
|
|
21
|
+
var useQueryClient_exports = {};
|
|
22
|
+
__export(useQueryClient_exports, {
|
|
23
|
+
useQueryClient: () => useQueryClient
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useQueryClient_exports);
|
|
26
|
+
var import_vue_demi = require("vue-demi");
|
|
27
|
+
var import_utils = require("./utils.cjs");
|
|
28
|
+
function useQueryClient(id = "") {
|
|
29
|
+
if (!(0, import_vue_demi.hasInjectionContext)()) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"vue-query hooks can only be used inside setup() function or functions that support injection context."
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const key = (0, import_utils.getClientKey)(id);
|
|
35
|
+
const queryClient = (0, import_vue_demi.inject)(key);
|
|
36
|
+
if (!queryClient) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library."
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return queryClient;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
useQueryClient
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=useQueryClient.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\nexport function useQueryClient(id = ''): QueryClient {\n // ensures that `inject()` can be used\n if (!hasInjectionContext()) {\n throw new Error(\n 'vue-query hooks can only be used inside setup() function or functions that support injection context.',\n )\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4C;AAE5C,mBAA6B;AAGtB,SAAS,eAAe,KAAK,IAAiB;AAEnD,MAAI,KAAC,qCAAoB,GAAG;AAC1B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAAM,2BAAa,EAAE;AAC3B,QAAM,kBAAc,wBAAoB,GAAG;AAE3C,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useQueryClient_alias_1 as useQueryClient } from './_tsup-dts-rollup.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useQueryClient_alias_1 as useQueryClient } from './_tsup-dts-rollup.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/useQueryClient.ts
|
|
2
|
+
import { hasInjectionContext, inject } from "vue-demi";
|
|
3
|
+
import { getClientKey } from "./utils.js";
|
|
4
|
+
function useQueryClient(id = "") {
|
|
5
|
+
if (!hasInjectionContext()) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"vue-query hooks can only be used inside setup() function or functions that support injection context."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
const key = getClientKey(id);
|
|
11
|
+
const queryClient = inject(key);
|
|
12
|
+
if (!queryClient) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library."
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return queryClient;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
useQueryClient
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useQueryClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useQueryClient.ts"],"sourcesContent":["import { hasInjectionContext, inject } from 'vue-demi'\n\nimport { getClientKey } from './utils'\nimport type { QueryClient } from './queryClient'\n\nexport function useQueryClient(id = ''): QueryClient {\n // ensures that `inject()` can be used\n if (!hasInjectionContext()) {\n throw new Error(\n 'vue-query hooks can only be used inside setup() function or functions that support injection context.',\n )\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"],"mappings":";AAAA,SAAS,qBAAqB,cAAc;AAE5C,SAAS,oBAAoB;AAGtB,SAAS,eAAe,KAAK,IAAiB;AAEnD,MAAI,CAAC,oBAAoB,GAAG;AAC1B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,MAAM,aAAa,EAAE;AAC3B,QAAM,cAAc,OAAoB,GAAG;AAE3C,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
VUE_QUERY_CLIENT: () => VUE_QUERY_CLIENT,
|
|
24
|
+
cloneDeep: () => cloneDeep,
|
|
25
|
+
cloneDeepUnref: () => cloneDeepUnref,
|
|
26
|
+
getClientKey: () => getClientKey,
|
|
27
|
+
updateState: () => updateState
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(utils_exports);
|
|
30
|
+
var import_vue_demi = require("vue-demi");
|
|
31
|
+
var VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
32
|
+
function getClientKey(key) {
|
|
33
|
+
const suffix = key ? `:${key}` : "";
|
|
34
|
+
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
35
|
+
}
|
|
36
|
+
function updateState(state, update) {
|
|
37
|
+
Object.keys(state).forEach((key) => {
|
|
38
|
+
state[key] = update[key];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
|
|
42
|
+
if (customize) {
|
|
43
|
+
const result = customize(value, currentKey, currentLevel);
|
|
44
|
+
if (result === void 0 && (0, import_vue_demi.isRef)(value)) {
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
if (result !== void 0) {
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
return value.map(
|
|
53
|
+
(val, index) => _cloneDeep(val, customize, String(index), currentLevel + 1)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === "object" && isPlainObject(value)) {
|
|
57
|
+
const entries = Object.entries(value).map(([key, val]) => [
|
|
58
|
+
key,
|
|
59
|
+
_cloneDeep(val, customize, key, currentLevel + 1)
|
|
60
|
+
]);
|
|
61
|
+
return Object.fromEntries(entries);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
function cloneDeep(value, customize) {
|
|
66
|
+
return _cloneDeep(value, customize);
|
|
67
|
+
}
|
|
68
|
+
function cloneDeepUnref(obj, unrefGetters = false) {
|
|
69
|
+
return cloneDeep(obj, (val, key, level) => {
|
|
70
|
+
if (level === 1 && key === "queryKey") {
|
|
71
|
+
return cloneDeepUnref(val, true);
|
|
72
|
+
}
|
|
73
|
+
if (unrefGetters && isFunction(val)) {
|
|
74
|
+
return cloneDeepUnref(val(), unrefGetters);
|
|
75
|
+
}
|
|
76
|
+
if ((0, import_vue_demi.isRef)(val)) {
|
|
77
|
+
return cloneDeepUnref((0, import_vue_demi.unref)(val), unrefGetters);
|
|
78
|
+
}
|
|
79
|
+
return void 0;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function isPlainObject(value) {
|
|
83
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const prototype = Object.getPrototypeOf(value);
|
|
87
|
+
return prototype === null || prototype === Object.prototype;
|
|
88
|
+
}
|
|
89
|
+
function isFunction(value) {
|
|
90
|
+
return typeof value === "function";
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
VUE_QUERY_CLIENT,
|
|
95
|
+
cloneDeep,
|
|
96
|
+
cloneDeepUnref,
|
|
97
|
+
getClientKey,
|
|
98
|
+
updateState
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\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, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) 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, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\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\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6B;AAGtB,IAAM,mBAAmB;AAEzB,SAAS,aAAa,KAAc;AACzC,QAAM,SAAS,MAAM,IAAI,GAAG,KAAK;AACjC,SAAO,GAAG,gBAAgB,GAAG,MAAM;AACrC;AAEO,SAAS,YACd,OACA,QACM;AACN,SAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,UAAM,GAAG,IAAI,OAAO,GAAG;AAAA,EACzB,CAAC;AACH;AAIA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;AACH,MAAI,WAAW;AACb,UAAM,SAAS,UAAU,OAAO,YAAY,YAAY;AACxD,QAAI,WAAW,cAAa,uBAAM,KAAK,GAAG;AACxC,aAAO;AAAA,IACT;AACA,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,CAAC,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;AACrD,UAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,MAAM;AAAA,MACxD;AAAA,MACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC;AAAA,IAClD,CAAC;AACD,WAAO,OAAO,YAAY,OAAO;AAAA,EACnC;AAEA,SAAO;AACT;AAEO,SAAS,UACd,OACA,WAKG;AACH,SAAO,WAAW,OAAO,SAAS;AACpC;AAEO,SAAS,eACd,KACA,eAAe,OACZ;AACH,SAAO,UAAU,KAAK,CAAC,KAAK,KAAK,UAAU;AAKzC,QAAI,UAAU,KAAK,QAAQ,YAAY;AACrC,aAAO,eAAe,KAAK,IAAI;AAAA,IACjC;AAGA,QAAI,gBAAgB,WAAW,GAAG,GAAG;AAGnC,aAAO,eAAgB,IAAiB,GAAG,YAAY;AAAA,IACzD;AAGA,YAAI,uBAAM,GAAG,GAAG;AACd,aAAO,mBAAe,uBAAM,GAAG,GAAG,YAAY;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAGA,SAAS,cAAc,OAAiC;AACtD,MAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAAmB;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,OAAO,UAAU;AAC1B;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getClientKey } from './_tsup-dts-rollup.cjs';
|
|
2
|
+
export { updateState } from './_tsup-dts-rollup.cjs';
|
|
3
|
+
export { cloneDeep } from './_tsup-dts-rollup.cjs';
|
|
4
|
+
export { cloneDeepUnref } from './_tsup-dts-rollup.cjs';
|
|
5
|
+
export { VUE_QUERY_CLIENT_alias_1 as VUE_QUERY_CLIENT } from './_tsup-dts-rollup.cjs';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getClientKey } from './_tsup-dts-rollup.js';
|
|
2
|
+
export { updateState } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { cloneDeep } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { cloneDeepUnref } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { VUE_QUERY_CLIENT_alias_1 as VUE_QUERY_CLIENT } from './_tsup-dts-rollup.js';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import { isRef, unref } from "vue-demi";
|
|
3
|
+
var VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
4
|
+
function getClientKey(key) {
|
|
5
|
+
const suffix = key ? `:${key}` : "";
|
|
6
|
+
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
7
|
+
}
|
|
8
|
+
function updateState(state, update) {
|
|
9
|
+
Object.keys(state).forEach((key) => {
|
|
10
|
+
state[key] = update[key];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
|
|
14
|
+
if (customize) {
|
|
15
|
+
const result = customize(value, currentKey, currentLevel);
|
|
16
|
+
if (result === void 0 && isRef(value)) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
if (result !== void 0) {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return value.map(
|
|
25
|
+
(val, index) => _cloneDeep(val, customize, String(index), currentLevel + 1)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === "object" && isPlainObject(value)) {
|
|
29
|
+
const entries = Object.entries(value).map(([key, val]) => [
|
|
30
|
+
key,
|
|
31
|
+
_cloneDeep(val, customize, key, currentLevel + 1)
|
|
32
|
+
]);
|
|
33
|
+
return Object.fromEntries(entries);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function cloneDeep(value, customize) {
|
|
38
|
+
return _cloneDeep(value, customize);
|
|
39
|
+
}
|
|
40
|
+
function cloneDeepUnref(obj, unrefGetters = false) {
|
|
41
|
+
return cloneDeep(obj, (val, key, level) => {
|
|
42
|
+
if (level === 1 && key === "queryKey") {
|
|
43
|
+
return cloneDeepUnref(val, true);
|
|
44
|
+
}
|
|
45
|
+
if (unrefGetters && isFunction(val)) {
|
|
46
|
+
return cloneDeepUnref(val(), unrefGetters);
|
|
47
|
+
}
|
|
48
|
+
if (isRef(val)) {
|
|
49
|
+
return cloneDeepUnref(unref(val), unrefGetters);
|
|
50
|
+
}
|
|
51
|
+
return void 0;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function isPlainObject(value) {
|
|
55
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const prototype = Object.getPrototypeOf(value);
|
|
59
|
+
return prototype === null || prototype === Object.prototype;
|
|
60
|
+
}
|
|
61
|
+
function isFunction(value) {
|
|
62
|
+
return typeof value === "function";
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
VUE_QUERY_CLIENT,
|
|
66
|
+
cloneDeep,
|
|
67
|
+
cloneDeepUnref,
|
|
68
|
+
getClientKey,
|
|
69
|
+
updateState
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n// Helper function for cloning deep objects where\n// the level and key is provided to the callback function.\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\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, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) 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, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\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\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n"],"mappings":";AAAA,SAAS,OAAO,aAAa;AAGtB,IAAM,mBAAmB;AAEzB,SAAS,aAAa,KAAc;AACzC,QAAM,SAAS,MAAM,IAAI,GAAG,KAAK;AACjC,SAAO,GAAG,gBAAgB,GAAG,MAAM;AACrC;AAEO,SAAS,YACd,O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MAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAAmB;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,SAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,OAAO,UAAU;AAC1B;","names":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/vueQueryPlugin.ts
|
|
21
|
+
var vueQueryPlugin_exports = {};
|
|
22
|
+
__export(vueQueryPlugin_exports, {
|
|
23
|
+
VueQueryPlugin: () => VueQueryPlugin
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(vueQueryPlugin_exports);
|
|
26
|
+
var import_vue_demi = require("vue-demi");
|
|
27
|
+
var import_query_core = require("@tanstack/query-core");
|
|
28
|
+
var import_queryClient = require("./queryClient.cjs");
|
|
29
|
+
var import_utils = require("./utils.cjs");
|
|
30
|
+
var import_devtools = require("./devtools/devtools.cjs");
|
|
31
|
+
var VueQueryPlugin = {
|
|
32
|
+
install: (app, options = {}) => {
|
|
33
|
+
const clientKey = (0, import_utils.getClientKey)(options.queryClientKey);
|
|
34
|
+
let client;
|
|
35
|
+
if ("queryClient" in options && options.queryClient) {
|
|
36
|
+
client = options.queryClient;
|
|
37
|
+
} else {
|
|
38
|
+
const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
|
|
39
|
+
client = new import_queryClient.QueryClient(clientConfig);
|
|
40
|
+
}
|
|
41
|
+
if (!import_query_core.isServer) {
|
|
42
|
+
client.mount();
|
|
43
|
+
}
|
|
44
|
+
let persisterUnmount = () => {
|
|
45
|
+
};
|
|
46
|
+
if (options.clientPersister) {
|
|
47
|
+
if (client.isRestoring) {
|
|
48
|
+
client.isRestoring.value = true;
|
|
49
|
+
}
|
|
50
|
+
const [unmount, promise] = options.clientPersister(client);
|
|
51
|
+
persisterUnmount = unmount;
|
|
52
|
+
promise.then(() => {
|
|
53
|
+
if (client.isRestoring) {
|
|
54
|
+
client.isRestoring.value = false;
|
|
55
|
+
}
|
|
56
|
+
options.clientPersisterOnSuccess?.(client);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const cleanup = () => {
|
|
60
|
+
client.unmount();
|
|
61
|
+
persisterUnmount();
|
|
62
|
+
};
|
|
63
|
+
if (app.onUnmount) {
|
|
64
|
+
app.onUnmount(cleanup);
|
|
65
|
+
} else {
|
|
66
|
+
const originalUnmount = app.unmount;
|
|
67
|
+
app.unmount = function vueQueryUnmount() {
|
|
68
|
+
cleanup();
|
|
69
|
+
originalUnmount();
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (import_vue_demi.isVue2) {
|
|
73
|
+
app.mixin({
|
|
74
|
+
beforeCreate() {
|
|
75
|
+
if (!this._provided) {
|
|
76
|
+
const provideCache = {};
|
|
77
|
+
Object.defineProperty(this, "_provided", {
|
|
78
|
+
get: () => provideCache,
|
|
79
|
+
set: (v) => Object.assign(provideCache, v)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
this._provided[clientKey] = client;
|
|
83
|
+
if (process.env.NODE_ENV === "development") {
|
|
84
|
+
if (this === this.$root && options.enableDevtoolsV6Plugin) {
|
|
85
|
+
(0, import_devtools.setupDevtools)(this, client);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
app.provide(clientKey, client);
|
|
92
|
+
if (process.env.NODE_ENV === "development") {
|
|
93
|
+
if (options.enableDevtoolsV6Plugin) {
|
|
94
|
+
(0, import_devtools.setupDevtools)(app, client);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
VueQueryPlugin
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=vueQueryPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuB;AACvB,wBAAyB;AAEzB,yBAA4B;AAC5B,mBAA6B;AAC7B,sBAA8B;AAsBvB,IAAM,iBAAiB;AAAA,EAC5B,SAAS,CAAC,KAAU,UAAiC,CAAC,MAAM;AAC1D,UAAM,gBAAY,2BAAa,QAAQ,cAAc;AACrD,QAAI;AAEJ,QAAI,iBAAiB,WAAW,QAAQ,aAAa;AAC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ACL,UAAI,QAAQ,WAAW,MAAM;AAE7B,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,QAAQ,wBAAwB;AAClC,6CAAc,KAAK,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/vueQueryPlugin.ts
|
|
2
|
+
import { isVue2 } from "vue-demi";
|
|
3
|
+
import { isServer } from "@tanstack/query-core";
|
|
4
|
+
import { QueryClient } from "./queryClient.js";
|
|
5
|
+
import { getClientKey } from "./utils.js";
|
|
6
|
+
import { setupDevtools } from "./devtools/devtools.js";
|
|
7
|
+
var VueQueryPlugin = {
|
|
8
|
+
install: (app, options = {}) => {
|
|
9
|
+
const clientKey = getClientKey(options.queryClientKey);
|
|
10
|
+
let client;
|
|
11
|
+
if ("queryClient" in options && options.queryClient) {
|
|
12
|
+
client = options.queryClient;
|
|
13
|
+
} else {
|
|
14
|
+
const clientConfig = "queryClientConfig" in options ? options.queryClientConfig : void 0;
|
|
15
|
+
client = new QueryClient(clientConfig);
|
|
16
|
+
}
|
|
17
|
+
if (!isServer) {
|
|
18
|
+
client.mount();
|
|
19
|
+
}
|
|
20
|
+
let persisterUnmount = () => {
|
|
21
|
+
};
|
|
22
|
+
if (options.clientPersister) {
|
|
23
|
+
if (client.isRestoring) {
|
|
24
|
+
client.isRestoring.value = true;
|
|
25
|
+
}
|
|
26
|
+
const [unmount, promise] = options.clientPersister(client);
|
|
27
|
+
persisterUnmount = unmount;
|
|
28
|
+
promise.then(() => {
|
|
29
|
+
if (client.isRestoring) {
|
|
30
|
+
client.isRestoring.value = false;
|
|
31
|
+
}
|
|
32
|
+
options.clientPersisterOnSuccess?.(client);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const cleanup = () => {
|
|
36
|
+
client.unmount();
|
|
37
|
+
persisterUnmount();
|
|
38
|
+
};
|
|
39
|
+
if (app.onUnmount) {
|
|
40
|
+
app.onUnmount(cleanup);
|
|
41
|
+
} else {
|
|
42
|
+
const originalUnmount = app.unmount;
|
|
43
|
+
app.unmount = function vueQueryUnmount() {
|
|
44
|
+
cleanup();
|
|
45
|
+
originalUnmount();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (isVue2) {
|
|
49
|
+
app.mixin({
|
|
50
|
+
beforeCreate() {
|
|
51
|
+
if (!this._provided) {
|
|
52
|
+
const provideCache = {};
|
|
53
|
+
Object.defineProperty(this, "_provided", {
|
|
54
|
+
get: () => provideCache,
|
|
55
|
+
set: (v) => Object.assign(provideCache, v)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
this._provided[clientKey] = client;
|
|
59
|
+
if (process.env.NODE_ENV === "development") {
|
|
60
|
+
if (this === this.$root && options.enableDevtoolsV6Plugin) {
|
|
61
|
+
setupDevtools(this, client);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
app.provide(clientKey, client);
|
|
68
|
+
if (process.env.NODE_ENV === "development") {
|
|
69
|
+
if (options.enableDevtoolsV6Plugin) {
|
|
70
|
+
setupDevtools(app, client);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
VueQueryPlugin
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=vueQueryPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n enableDevtoolsV6Plugin?: boolean\n queryClientKey?: string\n clientPersister?: ClientPersister\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,S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AAAA,YAC3C,CAAC;AAAA,UACH;AAEA,eAAK,UAAU,SAAS,IAAI;AAE5B,cAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,gBAAI,SAAS,KAAK,SAAS,QAAQ,wBAAwB;AACzD,4BAAc,MAAM,MAAM;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,UAAI,QAAQ,WAAW,MAAM;AAE7B,UAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAI,QAAQ,wBAAwB;AAClC,wBAAc,KAAK,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-query",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.95.0",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
|
|
5
5
|
"author": "Damian Osipiuk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@tanstack/match-sorter-utils": "^8.19.4",
|
|
43
43
|
"@vue/devtools-api": "^6.6.3",
|
|
44
44
|
"vue-demi": "^0.14.10",
|
|
45
|
-
"@tanstack/query-core": "5.
|
|
45
|
+
"@tanstack/query-core": "5.95.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@vitejs/plugin-vue": "^5.2.4",
|