@tanstack/vue-query 5.0.0-alpha.61 → 5.0.0-alpha.64
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/devtools/devtools.legacy.cjs +198 -0
- package/build/lib/devtools/devtools.legacy.cjs.map +1 -0
- package/build/lib/devtools/devtools.legacy.js +196 -0
- package/build/lib/devtools/devtools.legacy.js.map +1 -0
- package/build/lib/devtools/utils.legacy.cjs +85 -0
- package/build/lib/devtools/utils.legacy.cjs.map +1 -0
- package/build/lib/devtools/utils.legacy.js +79 -0
- package/build/lib/devtools/utils.legacy.js.map +1 -0
- package/build/lib/index.legacy.cjs +38 -0
- package/build/lib/index.legacy.cjs.map +1 -0
- package/build/lib/index.legacy.js +14 -0
- package/build/lib/index.legacy.js.map +1 -0
- package/build/lib/mutationCache.legacy.cjs +16 -0
- package/build/lib/mutationCache.legacy.cjs.map +1 -0
- package/build/lib/mutationCache.legacy.js +14 -0
- package/build/lib/mutationCache.legacy.js.map +1 -0
- package/build/lib/queryCache.legacy.cjs +16 -0
- package/build/lib/queryCache.legacy.cjs.map +1 -0
- package/build/lib/queryCache.legacy.js +14 -0
- package/build/lib/queryCache.legacy.js.map +1 -0
- package/build/lib/queryClient.legacy.cjs +86 -0
- package/build/lib/queryClient.legacy.cjs.map +1 -0
- package/build/lib/queryClient.legacy.js +84 -0
- package/build/lib/queryClient.legacy.js.map +1 -0
- package/build/lib/useBaseQuery.cjs +9 -9
- package/build/lib/useBaseQuery.cjs.map +1 -1
- package/build/lib/useBaseQuery.d.ts.map +1 -1
- package/build/lib/useBaseQuery.js +10 -10
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.legacy.cjs +69 -0
- package/build/lib/useBaseQuery.legacy.cjs.map +1 -0
- package/build/lib/useBaseQuery.legacy.js +67 -0
- package/build/lib/useBaseQuery.legacy.js.map +1 -0
- package/build/lib/useInfiniteQuery.legacy.cjs +20 -0
- package/build/lib/useInfiniteQuery.legacy.cjs.map +1 -0
- package/build/lib/useInfiniteQuery.legacy.js +18 -0
- package/build/lib/useInfiniteQuery.legacy.js.map +1 -0
- package/build/lib/useIsFetching.cjs +4 -1
- package/build/lib/useIsFetching.cjs.map +1 -1
- package/build/lib/useIsFetching.d.ts.map +1 -1
- package/build/lib/useIsFetching.js +5 -2
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.legacy.cjs +29 -0
- package/build/lib/useIsFetching.legacy.cjs.map +1 -0
- package/build/lib/useIsFetching.legacy.js +27 -0
- package/build/lib/useIsFetching.legacy.js.map +1 -0
- package/build/lib/useMutation.cjs +3 -1
- package/build/lib/useMutation.cjs.map +1 -1
- package/build/lib/useMutation.d.ts.map +1 -1
- package/build/lib/useMutation.js +5 -3
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.legacy.cjs +43 -0
- package/build/lib/useMutation.legacy.cjs.map +1 -0
- package/build/lib/useMutation.legacy.js +41 -0
- package/build/lib/useMutation.legacy.js.map +1 -0
- package/build/lib/useMutationState.legacy.cjs +36 -0
- package/build/lib/useMutationState.legacy.cjs.map +1 -0
- package/build/lib/useMutationState.legacy.js +33 -0
- package/build/lib/useMutationState.legacy.js.map +1 -0
- package/build/lib/useQueries.cjs +8 -7
- package/build/lib/useQueries.cjs.map +1 -1
- package/build/lib/useQueries.d.ts.map +1 -1
- package/build/lib/useQueries.js +10 -9
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.legacy.cjs +63 -0
- package/build/lib/useQueries.legacy.cjs.map +1 -0
- package/build/lib/useQueries.legacy.js +61 -0
- package/build/lib/useQueries.legacy.js.map +1 -0
- package/build/lib/useQuery.legacy.cjs +15 -0
- package/build/lib/useQuery.legacy.cjs.map +1 -0
- package/build/lib/useQuery.legacy.js +13 -0
- package/build/lib/useQuery.legacy.js.map +1 -0
- package/build/lib/useQueryClient.legacy.cjs +21 -0
- package/build/lib/useQueryClient.legacy.cjs.map +1 -0
- package/build/lib/useQueryClient.legacy.js +19 -0
- package/build/lib/useQueryClient.legacy.js.map +1 -0
- package/build/lib/utils.cjs +4 -0
- package/build/lib/utils.cjs.map +1 -1
- package/build/lib/utils.d.ts +1 -0
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +4 -1
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.legacy.cjs +60 -0
- package/build/lib/utils.legacy.cjs.map +1 -0
- package/build/lib/utils.legacy.js +53 -0
- package/build/lib/utils.legacy.js.map +1 -0
- package/build/lib/vueQueryPlugin.cjs +1 -3
- package/build/lib/vueQueryPlugin.cjs.map +1 -1
- package/build/lib/vueQueryPlugin.d.ts.map +1 -1
- package/build/lib/vueQueryPlugin.js +2 -4
- package/build/lib/vueQueryPlugin.js.map +1 -1
- package/build/lib/vueQueryPlugin.legacy.cjs +73 -0
- package/build/lib/vueQueryPlugin.legacy.cjs.map +1 -0
- package/build/lib/vueQueryPlugin.legacy.js +71 -0
- package/build/lib/vueQueryPlugin.legacy.js.map +1 -0
- package/package.json +3 -3
- package/src/useBaseQuery.ts +10 -10
- package/src/useIsFetching.ts +8 -4
- package/src/useMutation.ts +8 -4
- package/src/useQueries.ts +12 -11
- package/src/utils.ts +4 -0
- package/src/vueQueryPlugin.ts +2 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vueDemi = require('vue-demi');
|
|
4
|
+
|
|
5
|
+
const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT';
|
|
6
|
+
function getClientKey(key) {
|
|
7
|
+
const suffix = key ? `:${key}` : '';
|
|
8
|
+
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
9
|
+
}
|
|
10
|
+
function updateState(state, update) {
|
|
11
|
+
Object.keys(state).forEach(key => {
|
|
12
|
+
state[key] = update[key];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function cloneDeep(value, customizer) {
|
|
16
|
+
if (customizer) {
|
|
17
|
+
const result = customizer(value);
|
|
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) {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
return value.map(val => cloneDeep(val, customizer));
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === 'object' && isPlainObject(value)) {
|
|
30
|
+
const entries = Object.entries(value).map(([key, val]) => [key, cloneDeep(val, customizer)]);
|
|
31
|
+
return Object.fromEntries(entries);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function cloneDeepUnref(obj) {
|
|
36
|
+
return cloneDeep(obj, val => {
|
|
37
|
+
if (vueDemi.isRef(val)) {
|
|
38
|
+
return cloneDeepUnref(vueDemi.unref(val));
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function isPlainObject(value) {
|
|
44
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const prototype = Object.getPrototypeOf(value);
|
|
48
|
+
return prototype === null || prototype === Object.prototype;
|
|
49
|
+
}
|
|
50
|
+
function noop() {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.VUE_QUERY_CLIENT = VUE_QUERY_CLIENT;
|
|
55
|
+
exports.cloneDeep = cloneDeep;
|
|
56
|
+
exports.cloneDeepUnref = cloneDeepUnref;
|
|
57
|
+
exports.getClientKey = getClientKey;
|
|
58
|
+
exports.noop = noop;
|
|
59
|
+
exports.updateState = updateState;
|
|
60
|
+
//# sourceMappingURL=utils.legacy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.legacy.cjs","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\nexport function noop(): void {\n return undefined\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","noop"],"mappings":";;;;AAGO,MAAMA,gBAAgB,GAAG,mBAAkB;AAE3C,SAASC,YAAYA,CAACC,GAAY,EAAE;EACzC,MAAMC,MAAM,GAAGD,GAAG,GAAI,IAAGA,GAAI,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O,CAAC,CAAA;AACpC,GAAA;AAEA,EAAA,OAAOV,KAAK,CAAA;AACd,CAAA;AAEO,SAASY,cAAcA,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,aAAaA,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,CAAA;AAEO,SAASI,IAAIA,GAAS;AAC3B,EAAA,OAAOhB,SAAS,CAAA;AAClB;;;;;;;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isRef, unref } from 'vue-demi';
|
|
2
|
+
|
|
3
|
+
const 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, customizer) {
|
|
14
|
+
if (customizer) {
|
|
15
|
+
const result = customizer(value);
|
|
16
|
+
// If it's a ref of undefined, return undefined
|
|
17
|
+
if (result === undefined && isRef(value)) {
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
if (result !== undefined) {
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
return value.map(val => cloneDeep(val, customizer));
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'object' && isPlainObject(value)) {
|
|
28
|
+
const entries = Object.entries(value).map(([key, val]) => [key, cloneDeep(val, customizer)]);
|
|
29
|
+
return Object.fromEntries(entries);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function cloneDeepUnref(obj) {
|
|
34
|
+
return cloneDeep(obj, val => {
|
|
35
|
+
if (isRef(val)) {
|
|
36
|
+
return cloneDeepUnref(unref(val));
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function isPlainObject(value) {
|
|
42
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const prototype = Object.getPrototypeOf(value);
|
|
46
|
+
return prototype === null || prototype === Object.prototype;
|
|
47
|
+
}
|
|
48
|
+
function noop() {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, noop, updateState };
|
|
53
|
+
//# sourceMappingURL=utils.legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.legacy.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\nexport function noop(): void {\n return undefined\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","noop"],"mappings":";;AAGO,MAAMA,gBAAgB,GAAG,mBAAkB;AAE3C,SAASC,YAAYA,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,WAAWA,CACzBC,KAA8B,EAC9BC,MAA2B,EACrB;EACNC,MAAM,CAACC,I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,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,aAAaA,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,CAAA;AAEO,SAASI,IAAIA,GAAS;AAC3B,EAAA,OAAOhB,SAAS,CAAA;AAClB;;;;"}
|
|
@@ -19,9 +19,7 @@ const VueQueryPlugin = {
|
|
|
19
19
|
if (!queryCore.isServer) {
|
|
20
20
|
client.mount();
|
|
21
21
|
}
|
|
22
|
-
let persisterUnmount =
|
|
23
|
-
// noop
|
|
24
|
-
};
|
|
22
|
+
let persisterUnmount = utils.noop;
|
|
25
23
|
if (options.clientPersister) {
|
|
26
24
|
client.isRestoring.value = true;
|
|
27
25
|
const [unmount, promise] = options.clientPersister(client);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.cjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<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 =
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.cjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey, noop } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<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 = noop\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\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) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAEA,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CA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M,CAAA;IACvB,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,iBAAiB,CAAC,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;CACpD;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG,aAAa,CAAA;AAEjE,eAAO,MAAM,cAAc;mBACV,GAAG,YAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.ts","sourceRoot":"","sources":["../../src/vueQueryPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,CAAC,MAAM,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;AAE3E,UAAU,aAAa;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,iBAAiB,CAAC,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;CACpD;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B;AAED,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG,aAAa,CAAA;AAEjE,eAAO,MAAM,cAAc;mBACV,GAAG,YAAW,qBAAqB;CAuEnD,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isVue2 } from 'vue-demi';
|
|
2
2
|
import { isServer } from '@tanstack/query-core';
|
|
3
3
|
import { QueryClient } from './queryClient.js';
|
|
4
|
-
import { getClientKey } from './utils.js';
|
|
4
|
+
import { getClientKey, noop } from './utils.js';
|
|
5
5
|
import { setupDevtools } from './devtools/devtools.js';
|
|
6
6
|
|
|
7
7
|
const VueQueryPlugin = {
|
|
@@ -17,9 +17,7 @@ const VueQueryPlugin = {
|
|
|
17
17
|
if (!isServer) {
|
|
18
18
|
client.mount();
|
|
19
19
|
}
|
|
20
|
-
let persisterUnmount =
|
|
21
|
-
// noop
|
|
22
|
-
};
|
|
20
|
+
let persisterUnmount = noop;
|
|
23
21
|
if (options.clientPersister) {
|
|
24
22
|
client.isRestoring.value = true;
|
|
25
23
|
const [unmount, promise] = options.clientPersister(client);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<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 =
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey, noop } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<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 = noop\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\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) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAEA,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,WAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,QAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAGC,IAAI,CAAA;IAE3B,IAAIb,OAAO,CAACc,eAAe,EAAE;AAC3BV,MAAAA,MAAM,CAACW,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGlB,OAAO,CAACc,eAAe,CAACV,MAAM,CAAC,CAAA;AAC1DQ,MAAAA,gBAAgB,GAAGK,OAAO,CAAA;MAC1B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ACF,WAAA;AACF,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,MAAM;AACLL,MAAAA,GAAG,CAACyC,OAAO,CAACvC,SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI+B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,aAAa,CAACxC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vueDemi = require('vue-demi');
|
|
4
|
+
var queryCore = require('@tanstack/query-core');
|
|
5
|
+
var queryClient = require('./queryClient.legacy.cjs');
|
|
6
|
+
var utils = require('./utils.legacy.cjs');
|
|
7
|
+
var devtools = require('./devtools/devtools.legacy.cjs');
|
|
8
|
+
|
|
9
|
+
const VueQueryPlugin = {
|
|
10
|
+
install: (app, options = {}) => {
|
|
11
|
+
const clientKey = utils.getClientKey(options.queryClientKey);
|
|
12
|
+
let client;
|
|
13
|
+
if ('queryClient' in options && options.queryClient) {
|
|
14
|
+
client = options.queryClient;
|
|
15
|
+
} else {
|
|
16
|
+
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
17
|
+
client = new queryClient.QueryClient(clientConfig);
|
|
18
|
+
}
|
|
19
|
+
if (!queryCore.isServer) {
|
|
20
|
+
client.mount();
|
|
21
|
+
}
|
|
22
|
+
let persisterUnmount = utils.noop;
|
|
23
|
+
if (options.clientPersister) {
|
|
24
|
+
client.isRestoring.value = true;
|
|
25
|
+
const [unmount, promise] = options.clientPersister(client);
|
|
26
|
+
persisterUnmount = unmount;
|
|
27
|
+
promise.then(() => {
|
|
28
|
+
client.isRestoring.value = false;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const cleanup = () => {
|
|
32
|
+
client.unmount();
|
|
33
|
+
persisterUnmount();
|
|
34
|
+
};
|
|
35
|
+
if (app.onUnmount) {
|
|
36
|
+
app.onUnmount(cleanup);
|
|
37
|
+
} else {
|
|
38
|
+
const originalUnmount = app.unmount;
|
|
39
|
+
app.unmount = function vueQueryUnmount() {
|
|
40
|
+
cleanup();
|
|
41
|
+
originalUnmount();
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (vueDemi.isVue2) {
|
|
45
|
+
app.mixin({
|
|
46
|
+
beforeCreate() {
|
|
47
|
+
// HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30
|
|
48
|
+
if (!this._provided) {
|
|
49
|
+
const provideCache = {};
|
|
50
|
+
Object.defineProperty(this, '_provided', {
|
|
51
|
+
get: () => provideCache,
|
|
52
|
+
set: v => Object.assign(provideCache, v)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
this._provided[clientKey] = client;
|
|
56
|
+
if (process.env.NODE_ENV === 'development') {
|
|
57
|
+
if (this === this.$root) {
|
|
58
|
+
devtools.setupDevtools(this, client);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
app.provide(clientKey, client);
|
|
65
|
+
if (process.env.NODE_ENV === 'development') {
|
|
66
|
+
devtools.setupDevtools(app, client);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.VueQueryPlugin = VueQueryPlugin;
|
|
73
|
+
//# sourceMappingURL=vueQueryPlugin.legacy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.legacy.cjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey, noop } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<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 = noop\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\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) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAEA,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,uBAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,kBAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAGC,UAAI,CAAA;IAE3B,IAAIb,OAAO,CAACc,eAAe,EAAE;AAC3BV,MAAAA,MAAM,CAACW,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGlB,OAAO,CAACc,eAAe,CAACV,MAAM,CAAC,CAAA;AAC1DQ,MAAAA,gBAAgB,GAAGK,OAAO,CAAA;MAC1BC,OAAO,CAACC,IAAI,CAAC,MAAM;AACjBf,QAAAA,MAAM,CAACW,WAAW,CAACC,KAAK,GAAG,KAAK,CAAA;AAClC,OAAC,CAAC,CAAA;AACJ,KAAA;IAEA,MAAMI,OAAO,GAAGA,MAAM;MACpBh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AG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,sBAAa,CAACxC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isVue2 } from 'vue-demi';
|
|
2
|
+
import { isServer } from '@tanstack/query-core';
|
|
3
|
+
import { QueryClient } from './queryClient.legacy.js';
|
|
4
|
+
import { getClientKey, noop } from './utils.legacy.js';
|
|
5
|
+
import { setupDevtools } from './devtools/devtools.legacy.js';
|
|
6
|
+
|
|
7
|
+
const 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 : undefined;
|
|
15
|
+
client = new QueryClient(clientConfig);
|
|
16
|
+
}
|
|
17
|
+
if (!isServer) {
|
|
18
|
+
client.mount();
|
|
19
|
+
}
|
|
20
|
+
let persisterUnmount = noop;
|
|
21
|
+
if (options.clientPersister) {
|
|
22
|
+
client.isRestoring.value = true;
|
|
23
|
+
const [unmount, promise] = options.clientPersister(client);
|
|
24
|
+
persisterUnmount = unmount;
|
|
25
|
+
promise.then(() => {
|
|
26
|
+
client.isRestoring.value = false;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const cleanup = () => {
|
|
30
|
+
client.unmount();
|
|
31
|
+
persisterUnmount();
|
|
32
|
+
};
|
|
33
|
+
if (app.onUnmount) {
|
|
34
|
+
app.onUnmount(cleanup);
|
|
35
|
+
} else {
|
|
36
|
+
const originalUnmount = app.unmount;
|
|
37
|
+
app.unmount = function vueQueryUnmount() {
|
|
38
|
+
cleanup();
|
|
39
|
+
originalUnmount();
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (isVue2) {
|
|
43
|
+
app.mixin({
|
|
44
|
+
beforeCreate() {
|
|
45
|
+
// HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30
|
|
46
|
+
if (!this._provided) {
|
|
47
|
+
const provideCache = {};
|
|
48
|
+
Object.defineProperty(this, '_provided', {
|
|
49
|
+
get: () => provideCache,
|
|
50
|
+
set: v => Object.assign(provideCache, v)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
this._provided[clientKey] = client;
|
|
54
|
+
if (process.env.NODE_ENV === 'development') {
|
|
55
|
+
if (this === this.$root) {
|
|
56
|
+
setupDevtools(this, client);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
app.provide(clientKey, client);
|
|
63
|
+
if (process.env.NODE_ENV === 'development') {
|
|
64
|
+
setupDevtools(app, client);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { VueQueryPlugin };
|
|
71
|
+
//# sourceMappingURL=vueQueryPlugin.legacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.legacy.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey, noop } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<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 = noop\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\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) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n setupDevtools(app, client)\n }\n }\n },\n}\n"],"names":["VueQueryPlugin","install","app","options","clientKey","getClientKey","queryClientKey","client","queryClient","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAEA,CAACC,GAAQ,EAA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alpha.
|
|
3
|
+
"version": "5.0.0-alpha.64",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
|
|
5
5
|
"author": "Damian Osipiuk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"types": "build/lib/index.d.ts",
|
|
19
|
-
"main": "build/lib/index.cjs",
|
|
20
|
-
"module": "build/lib/index.js",
|
|
19
|
+
"main": "build/lib/index.legacy.cjs",
|
|
20
|
+
"module": "build/lib/index.legacy.js",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./build/lib/index.d.ts",
|
package/src/useBaseQuery.ts
CHANGED
|
@@ -14,8 +14,9 @@ import type {
|
|
|
14
14
|
QueryObserverResult,
|
|
15
15
|
DefaultedQueryObserverOptions,
|
|
16
16
|
} from '@tanstack/query-core'
|
|
17
|
+
import { isServer } from '@tanstack/query-core'
|
|
17
18
|
import { useQueryClient } from './useQueryClient'
|
|
18
|
-
import { updateState, cloneDeepUnref } from './utils'
|
|
19
|
+
import { updateState, cloneDeepUnref, noop } from './utils'
|
|
19
20
|
import type { QueryClient } from './queryClient'
|
|
20
21
|
import type { UseQueryOptions } from './useQuery'
|
|
21
22
|
import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
|
|
@@ -86,9 +87,7 @@ export function useBaseQuery<
|
|
|
86
87
|
const observer = new Observer(client, defaultedOptions.value)
|
|
87
88
|
const state = reactive(observer.getCurrentResult())
|
|
88
89
|
|
|
89
|
-
const unsubscribe = ref(
|
|
90
|
-
// noop
|
|
91
|
-
})
|
|
90
|
+
const unsubscribe = ref(noop)
|
|
92
91
|
|
|
93
92
|
watch(
|
|
94
93
|
client.isRestoring,
|
|
@@ -96,9 +95,12 @@ export function useBaseQuery<
|
|
|
96
95
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
97
96
|
if (!isRestoring) {
|
|
98
97
|
unsubscribe.value()
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
// Nuxt2 memory leak fix - do not subscribe on server
|
|
99
|
+
if (!isServer) {
|
|
100
|
+
unsubscribe.value = observer.subscribe((result) => {
|
|
101
|
+
updateState(state, result)
|
|
102
|
+
})
|
|
103
|
+
}
|
|
102
104
|
}
|
|
103
105
|
},
|
|
104
106
|
{ immediate: true },
|
|
@@ -119,9 +121,7 @@ export function useBaseQuery<
|
|
|
119
121
|
|
|
120
122
|
const suspense = () => {
|
|
121
123
|
return new Promise<QueryObserverResult<TData, TError>>((resolve) => {
|
|
122
|
-
let stopWatch =
|
|
123
|
-
//noop
|
|
124
|
-
}
|
|
124
|
+
let stopWatch = noop
|
|
125
125
|
const run = () => {
|
|
126
126
|
if (defaultedOptions.value.enabled !== false) {
|
|
127
127
|
const optimisticResult = observer.getOptimisticResult(
|
package/src/useIsFetching.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { computed, onScopeDispose, ref, watch } from 'vue-demi'
|
|
2
2
|
import type { Ref } from 'vue-demi'
|
|
3
3
|
import type { QueryFilters as QF } from '@tanstack/query-core'
|
|
4
|
+
import { isServer } from '@tanstack/query-core'
|
|
4
5
|
import { useQueryClient } from './useQueryClient'
|
|
5
|
-
import { cloneDeepUnref } from './utils'
|
|
6
|
+
import { cloneDeepUnref, noop } from './utils'
|
|
6
7
|
import type { MaybeRefDeep } from './types'
|
|
7
8
|
import type { QueryClient } from './queryClient'
|
|
8
9
|
|
|
@@ -17,9 +18,12 @@ export function useIsFetching(
|
|
|
17
18
|
|
|
18
19
|
const isFetching = ref(client.isFetching(filters))
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Nuxt2 memory leak fix - do not subscribe on server
|
|
22
|
+
const unsubscribe = isServer
|
|
23
|
+
? noop
|
|
24
|
+
: client.getQueryCache().subscribe(() => {
|
|
25
|
+
isFetching.value = client.isFetching(filters)
|
|
26
|
+
})
|
|
23
27
|
|
|
24
28
|
watch(
|
|
25
29
|
filters,
|
package/src/useMutation.ts
CHANGED
|
@@ -14,9 +14,10 @@ import type {
|
|
|
14
14
|
MutationObserverOptions,
|
|
15
15
|
DefaultError,
|
|
16
16
|
} from '@tanstack/query-core'
|
|
17
|
+
import { isServer } from '@tanstack/query-core'
|
|
17
18
|
import type { MaybeRefDeep, DistributiveOmit } from './types'
|
|
18
19
|
import { MutationObserver } from '@tanstack/query-core'
|
|
19
|
-
import { cloneDeepUnref, updateState } from './utils'
|
|
20
|
+
import { cloneDeepUnref, updateState, noop } from './utils'
|
|
20
21
|
import { useQueryClient } from './useQueryClient'
|
|
21
22
|
import type { QueryClient } from './queryClient'
|
|
22
23
|
|
|
@@ -71,9 +72,12 @@ export function useMutation<
|
|
|
71
72
|
const observer = new MutationObserver(client, options.value)
|
|
72
73
|
const state = reactive(observer.getCurrentResult())
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
// Nuxt2 memory leak fix - do not subscribe on server
|
|
76
|
+
const unsubscribe = isServer
|
|
77
|
+
? noop
|
|
78
|
+
: observer.subscribe((result) => {
|
|
79
|
+
updateState(state, result)
|
|
80
|
+
})
|
|
77
81
|
|
|
78
82
|
const mutate = (
|
|
79
83
|
variables: TVariables,
|
package/src/useQueries.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { QueriesObserver } from '@tanstack/query-core'
|
|
2
|
+
import { isServer, QueriesObserver } from '@tanstack/query-core'
|
|
3
3
|
import type {
|
|
4
4
|
QueriesPlaceholderDataFunction,
|
|
5
5
|
QueryKey,
|
|
@@ -11,7 +11,7 @@ import type { Ref } from 'vue-demi'
|
|
|
11
11
|
import { computed, onScopeDispose, readonly, ref, watch } from 'vue-demi'
|
|
12
12
|
|
|
13
13
|
import { useQueryClient } from './useQueryClient'
|
|
14
|
-
import { cloneDeepUnref } from './utils'
|
|
14
|
+
import { cloneDeepUnref, noop } from './utils'
|
|
15
15
|
import type { UseQueryOptions } from './useQuery'
|
|
16
16
|
import type { QueryClient } from './queryClient'
|
|
17
17
|
import type { DistributiveOmit, MaybeRefDeep } from './types'
|
|
@@ -182,21 +182,22 @@ export function useQueries<
|
|
|
182
182
|
)
|
|
183
183
|
const state = ref(getCombinedResult()) as Ref<TCombinedResult>
|
|
184
184
|
|
|
185
|
-
const unsubscribe = ref(
|
|
186
|
-
// noop
|
|
187
|
-
})
|
|
185
|
+
const unsubscribe = ref(noop)
|
|
188
186
|
|
|
189
187
|
watch(
|
|
190
188
|
client.isRestoring,
|
|
191
189
|
(isRestoring) => {
|
|
192
190
|
if (!isRestoring) {
|
|
193
191
|
unsubscribe.value()
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
192
|
+
// Nuxt2 memory leak fix - do not subscribe on server
|
|
193
|
+
if (!isServer) {
|
|
194
|
+
unsubscribe.value = observer.subscribe(() => {
|
|
195
|
+
const [, getCombinedResultRestoring] = observer.getOptimisticResult(
|
|
196
|
+
defaultedQueries.value,
|
|
197
|
+
)
|
|
198
|
+
state.value = getCombinedResultRestoring()
|
|
199
|
+
})
|
|
200
|
+
}
|
|
200
201
|
// Subscription would not fire for persisted results
|
|
201
202
|
const [, getCombinedResultPersisted] = observer.getOptimisticResult(
|
|
202
203
|
defaultedQueries.value,
|
package/src/utils.ts
CHANGED
package/src/vueQueryPlugin.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { isServer } from '@tanstack/query-core'
|
|
|
3
3
|
import type { QueryClientConfig } from '@tanstack/query-core'
|
|
4
4
|
|
|
5
5
|
import { QueryClient } from './queryClient'
|
|
6
|
-
import { getClientKey } from './utils'
|
|
6
|
+
import { getClientKey, noop } from './utils'
|
|
7
7
|
import { setupDevtools } from './devtools/devtools'
|
|
8
8
|
import type { MaybeRefDeep } from './types'
|
|
9
9
|
|
|
@@ -41,9 +41,7 @@ export const VueQueryPlugin = {
|
|
|
41
41
|
client.mount()
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
let persisterUnmount =
|
|
45
|
-
// noop
|
|
46
|
-
}
|
|
44
|
+
let persisterUnmount = noop
|
|
47
45
|
|
|
48
46
|
if (options.clientPersister) {
|
|
49
47
|
client.isRestoring.value = true
|