@tanstack/vue-query 5.0.0-alpha.61 → 5.0.0-alpha.63

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.
Files changed (65) hide show
  1. package/build/lib/devtools/devtools.legacy.cjs +198 -0
  2. package/build/lib/devtools/devtools.legacy.cjs.map +1 -0
  3. package/build/lib/devtools/devtools.legacy.js +196 -0
  4. package/build/lib/devtools/devtools.legacy.js.map +1 -0
  5. package/build/lib/devtools/utils.legacy.cjs +85 -0
  6. package/build/lib/devtools/utils.legacy.cjs.map +1 -0
  7. package/build/lib/devtools/utils.legacy.js +79 -0
  8. package/build/lib/devtools/utils.legacy.js.map +1 -0
  9. package/build/lib/index.legacy.cjs +38 -0
  10. package/build/lib/index.legacy.cjs.map +1 -0
  11. package/build/lib/index.legacy.js +14 -0
  12. package/build/lib/index.legacy.js.map +1 -0
  13. package/build/lib/mutationCache.legacy.cjs +16 -0
  14. package/build/lib/mutationCache.legacy.cjs.map +1 -0
  15. package/build/lib/mutationCache.legacy.js +14 -0
  16. package/build/lib/mutationCache.legacy.js.map +1 -0
  17. package/build/lib/queryCache.legacy.cjs +16 -0
  18. package/build/lib/queryCache.legacy.cjs.map +1 -0
  19. package/build/lib/queryCache.legacy.js +14 -0
  20. package/build/lib/queryCache.legacy.js.map +1 -0
  21. package/build/lib/queryClient.legacy.cjs +86 -0
  22. package/build/lib/queryClient.legacy.cjs.map +1 -0
  23. package/build/lib/queryClient.legacy.js +84 -0
  24. package/build/lib/queryClient.legacy.js.map +1 -0
  25. package/build/lib/useBaseQuery.legacy.cjs +69 -0
  26. package/build/lib/useBaseQuery.legacy.cjs.map +1 -0
  27. package/build/lib/useBaseQuery.legacy.js +67 -0
  28. package/build/lib/useBaseQuery.legacy.js.map +1 -0
  29. package/build/lib/useInfiniteQuery.legacy.cjs +20 -0
  30. package/build/lib/useInfiniteQuery.legacy.cjs.map +1 -0
  31. package/build/lib/useInfiniteQuery.legacy.js +18 -0
  32. package/build/lib/useInfiniteQuery.legacy.js.map +1 -0
  33. package/build/lib/useIsFetching.legacy.cjs +26 -0
  34. package/build/lib/useIsFetching.legacy.cjs.map +1 -0
  35. package/build/lib/useIsFetching.legacy.js +24 -0
  36. package/build/lib/useIsFetching.legacy.js.map +1 -0
  37. package/build/lib/useMutation.legacy.cjs +41 -0
  38. package/build/lib/useMutation.legacy.cjs.map +1 -0
  39. package/build/lib/useMutation.legacy.js +39 -0
  40. package/build/lib/useMutation.legacy.js.map +1 -0
  41. package/build/lib/useMutationState.legacy.cjs +36 -0
  42. package/build/lib/useMutationState.legacy.cjs.map +1 -0
  43. package/build/lib/useMutationState.legacy.js +33 -0
  44. package/build/lib/useMutationState.legacy.js.map +1 -0
  45. package/build/lib/useQueries.legacy.cjs +62 -0
  46. package/build/lib/useQueries.legacy.cjs.map +1 -0
  47. package/build/lib/useQueries.legacy.js +60 -0
  48. package/build/lib/useQueries.legacy.js.map +1 -0
  49. package/build/lib/useQuery.legacy.cjs +15 -0
  50. package/build/lib/useQuery.legacy.cjs.map +1 -0
  51. package/build/lib/useQuery.legacy.js +13 -0
  52. package/build/lib/useQuery.legacy.js.map +1 -0
  53. package/build/lib/useQueryClient.legacy.cjs +21 -0
  54. package/build/lib/useQueryClient.legacy.cjs.map +1 -0
  55. package/build/lib/useQueryClient.legacy.js +19 -0
  56. package/build/lib/useQueryClient.legacy.js.map +1 -0
  57. package/build/lib/utils.legacy.cjs +56 -0
  58. package/build/lib/utils.legacy.cjs.map +1 -0
  59. package/build/lib/utils.legacy.js +50 -0
  60. package/build/lib/utils.legacy.js.map +1 -0
  61. package/build/lib/vueQueryPlugin.legacy.cjs +75 -0
  62. package/build/lib/vueQueryPlugin.legacy.cjs.map +1 -0
  63. package/build/lib/vueQueryPlugin.legacy.js +73 -0
  64. package/build/lib/vueQueryPlugin.legacy.js.map +1 -0
  65. package/package.json +3 -3
@@ -0,0 +1,50 @@
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
+
49
+ export { VUE_QUERY_CLIENT, cloneDeep, cloneDeepUnref, getClientKey, updateState };
50
+ //# 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"],"names":["VUE_QUERY_CLIENT","getClientKey","key","suffix","updateState","state","update","Object","keys","forEach","cloneDeep","value","customizer","result","undefined","isRef","Array","isArray","map","val","isPlainObject","entries","fromEntries","cloneDeepUnref","obj","unref","prototype","toString","call","getPrototypeOf"],"mappings":";;AAGO,MAAMA,gBAAgB,GAAG,mBAAkB;AAE3C,SAASC,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,IAAI,CAACH,KAAK,CAAC,CAACI,OAAO,CAAEP,GAAG,IAAK;AAClCG,IAAAA,KAAK,CAACH,GAAG,CAAC,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AAA;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;;;;"}
@@ -0,0 +1,75 @@
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 = () => {
23
+ // noop
24
+ };
25
+ if (options.clientPersister) {
26
+ client.isRestoring.value = true;
27
+ const [unmount, promise] = options.clientPersister(client);
28
+ persisterUnmount = unmount;
29
+ promise.then(() => {
30
+ client.isRestoring.value = false;
31
+ });
32
+ }
33
+ const cleanup = () => {
34
+ client.unmount();
35
+ persisterUnmount();
36
+ };
37
+ if (app.onUnmount) {
38
+ app.onUnmount(cleanup);
39
+ } else {
40
+ const originalUnmount = app.unmount;
41
+ app.unmount = function vueQueryUnmount() {
42
+ cleanup();
43
+ originalUnmount();
44
+ };
45
+ }
46
+ if (vueDemi.isVue2) {
47
+ app.mixin({
48
+ beforeCreate() {
49
+ // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30
50
+ if (!this._provided) {
51
+ const provideCache = {};
52
+ Object.defineProperty(this, '_provided', {
53
+ get: () => provideCache,
54
+ set: v => Object.assign(provideCache, v)
55
+ });
56
+ }
57
+ this._provided[clientKey] = client;
58
+ if (process.env.NODE_ENV === 'development') {
59
+ if (this === this.$root) {
60
+ devtools.setupDevtools(this, client);
61
+ }
62
+ }
63
+ }
64
+ });
65
+ } else {
66
+ app.provide(clientKey, client);
67
+ if (process.env.NODE_ENV === 'development') {
68
+ devtools.setupDevtools(app, client);
69
+ }
70
+ }
71
+ }
72
+ };
73
+
74
+ exports.VueQueryPlugin = VueQueryPlugin;
75
+ //# 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 } 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 = () => {\n // noop\n }\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","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,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A,IAAA,IAAIE,cAAM,EAAE;MACVxB,GAAG,CAACyB,KAAK,CAAC;AACRC,QAAAA,YAAYA,GAAG;AACb;AACA,UAAA,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;YACnB,MAAMC,YAAY,GAAG,EAAE,CAAA;AACvBC,YAAAA,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE;cACvCC,GAAG,EAAEA,MAAMH,YAAY;cACvBI,GAAG,EAAGC,CAAC,IAAKJ,MAAM,CAACK,MAAM,CAACN,YAAY,EAAEK,CAAC,CAAA;AAC3C,aAAC,CAAC,CAAA;AACJ,WAAA;AAEA,UAAA,IAAI,CAACN,SAAS,CAACzB,SAAS,CAAC,GAAGG,MAAM,CAAA;AAElC,UAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1C,YAAA,IAAI,IAAI,KAAK,IAAI,CAACC,KAAK,EAAE;AACvBC,cAAAA,sBAAa,CAAC,IAAI,EAAElC,MAAM,CAAC,CAAA;AAC7B,aAAA;AACF,WAAA;AACF,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,MAAM;AACLL,MAAAA,GAAG,CAACwC,OAAO,CAACtC,SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,sBAAa,CAACvC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
@@ -0,0 +1,73 @@
1
+ import { isVue2 } from 'vue-demi';
2
+ import { isServer } from '@tanstack/query-core';
3
+ import { QueryClient } from './queryClient.legacy.js';
4
+ import { getClientKey } 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 = () => {
21
+ // noop
22
+ };
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 (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
+ setupDevtools(this, client);
59
+ }
60
+ }
61
+ }
62
+ });
63
+ } else {
64
+ app.provide(clientKey, client);
65
+ if (process.env.NODE_ENV === 'development') {
66
+ setupDevtools(app, client);
67
+ }
68
+ }
69
+ }
70
+ };
71
+
72
+ export { VueQueryPlugin };
73
+ //# 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 } 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 = () => {\n // noop\n }\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","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,GAAGA,MAAM;AAC3B;KACD,CAAA;IAED,IAAIZ,OAAO,CAACa,eAAe,EAAE;AAC3BT,MAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGjB,OAAO,CAACa,eAAe,CAACT,MAAM,CAAC,CAAA;AAC1DQ,MAAAA,gBAAgB,GAAGI,OAAO,CAAA;MAC1BC,OAAO,CAACC,IAAI,CAAC,MAAM;AACjBd,QAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,KAAK,CAAA;AACl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SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,aAAa,CAACvC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-query",
3
- "version": "5.0.0-alpha.61",
3
+ "version": "5.0.0-alpha.63",
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",