@tanstack/vue-query 4.29.10 → 4.29.13

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 (84) hide show
  1. package/README.md +18 -14
  2. package/build/lib/useBaseQuery.esm.js +11 -9
  3. package/build/lib/useBaseQuery.esm.js.map +1 -1
  4. package/build/lib/useBaseQuery.js +10 -8
  5. package/build/lib/useBaseQuery.js.map +1 -1
  6. package/build/lib/useBaseQuery.mjs +11 -9
  7. package/build/lib/useBaseQuery.mjs.map +1 -1
  8. package/build/lib/useIsFetching.esm.js +5 -3
  9. package/build/lib/useIsFetching.esm.js.map +1 -1
  10. package/build/lib/useIsFetching.js +4 -2
  11. package/build/lib/useIsFetching.js.map +1 -1
  12. package/build/lib/useIsFetching.mjs +5 -3
  13. package/build/lib/useIsFetching.mjs.map +1 -1
  14. package/build/lib/useIsMutating.esm.js +5 -3
  15. package/build/lib/useIsMutating.esm.js.map +1 -1
  16. package/build/lib/useIsMutating.js +4 -2
  17. package/build/lib/useIsMutating.js.map +1 -1
  18. package/build/lib/useIsMutating.mjs +5 -3
  19. package/build/lib/useIsMutating.mjs.map +1 -1
  20. package/build/lib/useMutation.esm.js +5 -4
  21. package/build/lib/useMutation.esm.js.map +1 -1
  22. package/build/lib/useMutation.js +3 -2
  23. package/build/lib/useMutation.js.map +1 -1
  24. package/build/lib/useMutation.mjs +5 -4
  25. package/build/lib/useMutation.mjs.map +1 -1
  26. package/build/lib/useQueries.esm.js +11 -8
  27. package/build/lib/useQueries.esm.js.map +1 -1
  28. package/build/lib/useQueries.js +9 -6
  29. package/build/lib/useQueries.js.map +1 -1
  30. package/build/lib/useQueries.mjs +11 -8
  31. package/build/lib/useQueries.mjs.map +1 -1
  32. package/build/lib/utils.d.ts +1 -0
  33. package/build/lib/utils.esm.js +5 -1
  34. package/build/lib/utils.esm.js.map +1 -1
  35. package/build/lib/utils.js +5 -0
  36. package/build/lib/utils.js.map +1 -1
  37. package/build/lib/utils.mjs +5 -1
  38. package/build/lib/utils.mjs.map +1 -1
  39. package/build/lib/vueQueryPlugin.esm.js +2 -3
  40. package/build/lib/vueQueryPlugin.esm.js.map +1 -1
  41. package/build/lib/vueQueryPlugin.js +1 -2
  42. package/build/lib/vueQueryPlugin.js.map +1 -1
  43. package/build/lib/vueQueryPlugin.mjs +2 -3
  44. package/build/lib/vueQueryPlugin.mjs.map +1 -1
  45. package/build/umd/index.development.js +45 -35
  46. package/build/umd/index.development.js.map +1 -1
  47. package/build/umd/index.production.js +1 -1
  48. package/build/umd/index.production.js.map +1 -1
  49. package/package.json +2 -2
  50. package/build/lib/__mocks__/useBaseQuery.d.ts.map +0 -1
  51. package/build/lib/__mocks__/useQueryClient.d.ts.map +0 -1
  52. package/build/lib/__tests__/mutationCache.test.d.ts.map +0 -1
  53. package/build/lib/__tests__/queryCache.test.d.ts.map +0 -1
  54. package/build/lib/__tests__/queryClient.test.d.ts.map +0 -1
  55. package/build/lib/__tests__/test-utils.d.ts.map +0 -1
  56. package/build/lib/__tests__/useInfiniteQuery.test.d.ts.map +0 -1
  57. package/build/lib/__tests__/useInfiniteQuery.types.test.d.ts.map +0 -1
  58. package/build/lib/__tests__/useIsFetching.test.d.ts.map +0 -1
  59. package/build/lib/__tests__/useIsMutating.test.d.ts.map +0 -1
  60. package/build/lib/__tests__/useMutation.test.d.ts.map +0 -1
  61. package/build/lib/__tests__/useMutation.types.test.d.ts.map +0 -1
  62. package/build/lib/__tests__/useQueries.test.d.ts.map +0 -1
  63. package/build/lib/__tests__/useQuery.test.d.ts.map +0 -1
  64. package/build/lib/__tests__/useQuery.types.test.d.ts.map +0 -1
  65. package/build/lib/__tests__/useQueryClient.test.d.ts.map +0 -1
  66. package/build/lib/__tests__/utils.test.d.ts.map +0 -1
  67. package/build/lib/__tests__/vueQueryPlugin.test.d.ts.map +0 -1
  68. package/build/lib/devtools/devtools.d.ts.map +0 -1
  69. package/build/lib/devtools/utils.d.ts.map +0 -1
  70. package/build/lib/index.d.ts.map +0 -1
  71. package/build/lib/mutationCache.d.ts.map +0 -1
  72. package/build/lib/queryCache.d.ts.map +0 -1
  73. package/build/lib/queryClient.d.ts.map +0 -1
  74. package/build/lib/types.d.ts.map +0 -1
  75. package/build/lib/useBaseQuery.d.ts.map +0 -1
  76. package/build/lib/useInfiniteQuery.d.ts.map +0 -1
  77. package/build/lib/useIsFetching.d.ts.map +0 -1
  78. package/build/lib/useIsMutating.d.ts.map +0 -1
  79. package/build/lib/useMutation.d.ts.map +0 -1
  80. package/build/lib/useQueries.d.ts.map +0 -1
  81. package/build/lib/useQuery.d.ts.map +0 -1
  82. package/build/lib/useQueryClient.d.ts.map +0 -1
  83. package/build/lib/utils.d.ts.map +0 -1
  84. package/build/lib/vueQueryPlugin.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { QueryKey, MutationKey } from '@tanstack/query-core'\nimport { isRef, unref } from 'vue-demi'\nimport type { UnwrapRef } from 'vue-demi'\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 isQueryKey(value: unknown): value is QueryKey {\n return Array.isArray(value)\n}\n\nexport function isMutationKey(value: unknown): value is MutationKey {\n return Array.isArray(value)\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: T,\n customizer?: (val: unknown) => unknown | void,\n): T {\n if (customizer) {\n const result = customizer(value)\n if (result !== undefined || isRef(value)) {\n return result as typeof value\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val) => cloneDeep(val, customizer)) as typeof value\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\n}\n\nexport function cloneDeepUnref<T>(obj: T): UnwrapRef<T> {\n return cloneDeep(obj, (val) => {\n if (isRef(val)) {\n return cloneDeepUnref(unref(val))\n }\n }) as UnwrapRef<typeof obj>\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","isQueryKey","value","Array","isArray","isMutationKey","updateState","state","update","Object","keys","forEach","cloneDeep","customizer","result","undefined","isRef","map","val","isPlainObject","entries","fromEntries","cloneDeepUnref","obj","unref","prototype","toString","call","getPrototypeOf"],"mappings":";;AAAA;AAKO,MAAMA,gBAAgB,GAAG,mBAAzB;AAEA,SAASC,YAAT,CAAsBC,GAAtB,EAAoC;AACzC,EAAA,MAAMC,MAAM,GAAGD,GAAG,GAAOA,GAAAA,GAAAA,GAAP,GAAe,EAAjC,CAAA;EACA,OAAUF,EAAAA,GAAAA,gBAAV,GAA6BG,MAA7B,CAAA;AACD,CAAA;AAEM,SAASC,UAAT,CAAoBC,KAApB,EAAuD;AAC5D,EAAA,OAAOC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAP,CAAA;AACD,CAAA;AAEM,SAASG,aAAT,CAAuBH,KAAvB,EAA6D;AAClE,EAAA,OAAOC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAP,CAAA;AACD,CAAA;AAEM,SAASI,WAAT,CACLC,KADK,EAELC,MAFK,EAGC;EACNC,MAAM,CAACC,IAAP,CAAYH,KAAZ,EAAmBI,OAAnB,CAA4BZ,GAAD,IAAS;AAClCQ,IAAAA,KAAK,CAACR,GAAD,CAAL,GAAaS,MAAM,CAACT,GAAD,CAAnB,CAAA;GADF,CAAA,CAAA;AAGD,CAAA;AAEM,SAASa,SAAT,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A/B,CAA0C,KAAA,iBAA9C,EAAiE;AAC/D,IAAA,OAAO,KAAP,CAAA;AACD,GAAA;;AAED,EAAA,MAAMuB,SAAS,GAAGhB,MAAM,CAACmB,cAAP,CAAsB1B,KAAtB,CAAlB,CAAA;EACA,OAAOuB,SAAS,KAAK,IAAd,IAAsBA,SAAS,KAAKhB,MAAM,CAACgB,SAAlD,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { QueryKey, MutationKey } from '@tanstack/query-core'\nimport { isRef, unref } from 'vue-demi'\nimport type { UnwrapRef } from 'vue-demi'\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 isQueryKey(value: unknown): value is QueryKey {\n return Array.isArray(value)\n}\n\nexport function isMutationKey(value: unknown): value is MutationKey {\n return Array.isArray(value)\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: T,\n customizer?: (val: unknown) => unknown | void,\n): T {\n if (customizer) {\n const result = customizer(value)\n if (result !== undefined || isRef(value)) {\n return result as typeof value\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val) => cloneDeep(val, customizer)) as typeof value\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\n}\n\nexport function cloneDeepUnref<T>(obj: T): UnwrapRef<T> {\n return cloneDeep(obj, (val) => {\n if (isRef(val)) {\n return cloneDeepUnref(unref(val))\n }\n }) as UnwrapRef<typeof obj>\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","isQueryKey","value","Array","isArray","isMutationKey","updateState","state","update","Object","keys","forEach","cloneDeep","customizer","result","undefined","isRef","map","val","isPlainObject","entries","fromEntries","cloneDeepUnref","obj","unref","prototype","toString","call","getPrototypeOf","noop"],"mappings":";;AAAA;AAKO,MAAMA,gBAAgB,GAAG,mBAAzB;AAEA,SAASC,YAAT,CAAsBC,GAAtB,EAAoC;AACzC,EAAA,MAAMC,MAAM,GAAGD,GAAG,GAAOA,GAAAA,GAAAA,GAAP,GAAe,EAAjC,CAAA;EACA,OAAUF,EAAAA,GAAAA,gBAAV,GAA6BG,MAA7B,CAAA;AACD,CAAA;AAEM,SAASC,UAAT,CAAoBC,KAApB,EAAuD;AAC5D,EAAA,OAAOC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAP,CAAA;AACD,CAAA;AAEM,SAASG,aAAT,CAAuBH,KAAvB,EAA6D;AAClE,EAAA,OAAOC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAP,CAAA;AACD,CAAA;AAEM,SAASI,WAAT,CACLC,KADK,EAELC,MAFK,EAGC;EACNC,MAAM,CAACC,IAAP,CAAYH,KAAZ,EAAmBI,OAAnB,CAA4BZ,GAAD,IAAS;AAClCQ,IAAAA,KAAK,CAACR,GAAD,CAAL,GAAaS,MAAM,CAACT,GAAD,CAAnB,CAAA;GADF,CAAA,CAAA;AAGD,CAAA;AAEM,SAASa,SAAT,CACLV,KADK,EAELW,UAFK,EAGF;AACH,EAAA,IAAIA,UAAJ,EAAgB;AACd,IAAA,MAAMC,MAAM,GAAGD,UAAU,CAACX,KAAD,CAAzB,CAAA;;IACA,IAAIY,MAAM,KAAKC,SAAX,IAAwBC,KAAK,CAACd,KAAD,CAAjC,EAA0C;AACxC,MAAA,OAAOY,MAA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CAACgB,SAAlD,CAAA;AACD,CAAA;;AAEM,SAASI,IAAT,GAAsB;AAC3B,EAAA,OAAOd,SAAP,CAAA;AACD;;;;"}
@@ -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.esm.js';
4
- import { getClientKey } from './utils.esm.js';
4
+ import { getClientKey, noop } from './utils.esm.js';
5
5
  import { setupDevtools } from './devtools/devtools.esm.js';
6
6
 
7
7
  const VueQueryPlugin = {
@@ -30,8 +30,7 @@ const VueQueryPlugin = {
30
30
  client.mount();
31
31
  }
32
32
 
33
- let persisterUnmount = () => {// noop
34
- };
33
+ let persisterUnmount = noop;
35
34
 
36
35
  if (options.clientPersister) {
37
36
  client.isRestoring.value = true;
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.esm.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\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\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 if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\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 if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\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 /* istanbul ignore next */\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","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;AAiCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAAAA,MAAM,GAAG,IAAIQ,WAAJ,CAAgBH,YAAhB,CAAT,CAAA;UACAF,MAAM,CAACC,qBAAP,GAA+BJ,MAA/B,CAAA;AACD,SAPD,MAOO;UACLA,MAAM,GAAGG,MAAM,CAACC,qBAAhB,CAAA;AACD,SAAA;AACF,OAXD,MAWO;QACL,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GAAiCA,OAAO,CAACU,iBAAzC,GAA6DC,SAD/D,CAAA;AAEAP,QAAAA,MAAM,GAAG,IAAIQ,WAAJ,CAAgBH,YAAhB,CAAT,CAAA;AACD,OAAA;AACF,KAAA;;IAED,IAAI,CAACI,QAAL,EAAe;AACbT,MAAAA,MAAM,CAACU,KAAP,EAAA,CAAA;AACD,KAAA;;IAED,IAAIC,gBAAgB,GAAG,MAAM;KAA7B,CAAA;;IAIA,IAAIf,O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C,GAAG,EAAE,MAAMH,YAD4B;cAEvCI,GAAG,EAAGC,CAAD,IAAOJ,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BK,CAA5B,CAAA;aAFd,CAAA,CAAA;AAID,WAAA;;AAED,UAAA,IAAA,CAAKN,SAAL,CAAejC,SAAf,CAAA,GAA4BG,MAA5B,CAAA;;AAEA,UAAA,IAAIkB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;YAC1C,IAAI,IAAA,KAAS,IAAKkB,CAAAA,KAAlB,EAAyB;AACvBC,cAAAA,aAAa,CAAC,IAAD,EAAOvC,MAAP,CAAb,CAAA;AACD,aAAA;AACF,WAAA;AACF,SAAA;;OAlBH,CAAA,CAAA;AAoBD,KArBD,MAqBO;AACLL,MAAAA,GAAG,CAAC6C,OAAJ,CAAY3C,SAAZ,EAAuBG,MAAvB,CAAA,CAAA;;AAEA,MAAA,IAAIkB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CmB,QAAAA,aAAa,CAAC5C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA/F2B;;;;"}
1
+ {"version":3,"file":"vueQueryPlugin.esm.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\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\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 if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\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 if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\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 /* istanbul ignore next */\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","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;AAiCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAAAA,MAAM,GAAG,IAAIQ,WAAJ,CAAgBH,YAAhB,CAAT,CAAA;UACAF,MAAM,CAACC,qBAAP,GAA+BJ,MAA/B,CAAA;AACD,SAPD,MAOO;UACLA,MAAM,GAAGG,MAAM,CAACC,qBAAhB,CAAA;AACD,SAAA;AACF,OAXD,MAWO;QACL,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GAAiCA,OAAO,CAACU,iBAAzC,GAA6DC,SAD/D,CAAA;AA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MAAJ,EAAY;MACVjC,GAAG,CAACkC,KAAJ,CAAU;AACRC,QAAAA,YAAY,GAAG;AACb;UACA,IAAI,CAAC,IAAKC,CAAAA,SAAV,EAAqB;YACnB,MAAMC,YAAY,GAAG,EAArB,CAAA;AACAC,YAAAA,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4B,WAA5B,EAAyC;cACvCC,GAAG,EAAE,MAAMH,YAD4B;cAEvCI,GAAG,EAAGC,CAAD,IAAOJ,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BK,CAA5B,CAAA;aAFd,CAAA,CAAA;AAID,WAAA;;AAED,UAAA,IAAA,CAAKN,SAAL,CAAelC,SAAf,CAAA,GAA4BG,MAA5B,CAAA;;AAEA,UAAA,IAAImB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;YAC1C,IAAI,IAAA,KAAS,IAAKkB,CAAAA,KAAlB,EAAyB;AACvBC,cAAAA,aAAa,CAAC,IAAD,EAAOxC,MAAP,CAAb,CAAA;AACD,aAAA;AACF,WAAA;AACF,SAAA;;OAlBH,CAAA,CAAA;AAoBD,KArBD,MAqBO;AACLL,MAAAA,GAAG,CAAC8C,OAAJ,CAAY5C,SAAZ,EAAuBG,MAAvB,CAAA,CAAA;;AAEA,MAAA,IAAImB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CmB,QAAAA,aAAa,CAAC7C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA7F2B;;;;"}
@@ -34,8 +34,7 @@ const VueQueryPlugin = {
34
34
  client.mount();
35
35
  }
36
36
 
37
- let persisterUnmount = () => {// noop
38
- };
37
+ let persisterUnmount = utils.noop;
39
38
 
40
39
  if (options.clientPersister) {
41
40
  client.isRestoring.value = true;
@@ -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\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\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 if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\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 if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\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 /* istanbul ignore next */\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","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;;;;;AAiCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAA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IkB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CmB,QAAAA,sBAAa,CAAC5C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA/F2B;;;;"}
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\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\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 if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\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 if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\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 /* istanbul ignore next */\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","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;;;;;AAiCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA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B,EAAyB;AACvBC,cAAAA,sBAAa,CAAC,IAAD,EAAOxC,MAAP,CAAb,CAAA;AACD,aAAA;AACF,WAAA;AACF,SAAA;;OAlBH,CAAA,CAAA;AAoBD,KArBD,MAqBO;AACLL,MAAAA,GAAG,CAAC8C,OAAJ,CAAY5C,SAAZ,EAAuBG,MAAvB,CAAA,CAAA;;AAEA,MAAA,IAAImB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CmB,QAAAA,sBAAa,CAAC7C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA7F2B;;;;"}
@@ -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.mjs';
4
- import { getClientKey } from './utils.mjs';
4
+ import { getClientKey, noop } from './utils.mjs';
5
5
  import { setupDevtools } from './devtools/devtools.mjs';
6
6
 
7
7
  const VueQueryPlugin = {
@@ -30,8 +30,7 @@ const VueQueryPlugin = {
30
30
  client.mount();
31
31
  }
32
32
 
33
- let persisterUnmount = () => {// noop
34
- };
33
+ let persisterUnmount = noop;
35
34
 
36
35
  if (options.clientPersister) {
37
36
  client.isRestoring.value = true;
@@ -1 +1 @@
1
- {"version":3,"file":"vueQueryPlugin.mjs","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\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\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 if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\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 if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\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 /* istanbul ignore next */\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","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;AAiCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAAAA,MAAM,GAAG,IAAIQ,WAAJ,CAAgBH,YAAhB,CAAT,CAAA;UACAF,MAAM,CAACC,qBAAP,GAA+BJ,MAA/B,CAAA;AACD,SAPD,MAOO;UACLA,MAAM,GAAGG,MAAM,CAACC,qBAAhB,CAAA;AACD,SAAA;AACF,OAXD,MAWO;QACL,MAAMC,YAAY,GAChB,mBAAuBT,IAA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,eAAe,EAAA,CAAA;OAFjB,CAAA;AAID,KAAA;AAED;;;AACA,IAAA,IAAIE,MAAJ,EAAY;MACVhC,GAAG,CAACiC,KAAJ,CAAU;AACRC,QAAAA,YAAY,GAAG;AACb;UACA,IAAI,CAAC,IAAKC,CAAAA,SAAV,EAAqB;YACnB,MAAMC,YAAY,GAAG,EAArB,CAAA;AACAC,YAAAA,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4B,WAA5B,EAAyC;cACvCC,GAAG,EAAE,MAAMH,YAD4B;cAEvCI,GAAG,EAAGC,CAAD,IAAOJ,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BK,CAA5B,CAAA;aAFd,CAAA,CAAA;AAID,WAAA;;AAED,UAAA,IAAA,CAAKN,SAAL,CAAejC,SAAf,CAAA,GAA4BG,MAA5B,CAAA;;AAEA,UAAA,IAAIkB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;YAC1C,IAAI,IAAA,KAAS,IAAKkB,CAAAA,KAAlB,EAAyB;AACvBC,cAAAA,aAAa,CAAC,IAAD,EAAOvC,MAAP,CAAb,CAAA;AACD,aAAA;AACF,WAAA;AACF,SAAA;;OAlBH,CAAA,CAAA;AAoBD,KArBD,MAqBO;AACLL,MAAAA,GAAG,CAAC6C,OAAJ,CAAY3C,SAAZ,EAAuBG,MAAvB,CAAA,CAAA;;AAEA,MAAA,IAAIkB,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CmB,QAAAA,aAAa,CAAC5C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA/F2B;;;;"}
1
+ {"version":3,"file":"vueQueryPlugin.mjs","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\ndeclare global {\n interface Window {\n __VUE_QUERY_CONTEXT__?: QueryClient\n }\n}\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n contextSharing?: boolean\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 if (options.contextSharing && typeof window !== 'undefined') {\n if (!window.__VUE_QUERY_CONTEXT__) {\n const clientConfig =\n 'queryClientConfig' in options\n ? options.queryClientConfig\n : undefined\n client = new QueryClient(clientConfig)\n window.__VUE_QUERY_CONTEXT__ = client\n } else {\n client = window.__VUE_QUERY_CONTEXT__\n }\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\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 if (process.env.NODE_ENV !== 'production' && options.contextSharing) {\n client\n .getLogger()\n .error(\n `The contextSharing option has been deprecated and will be removed in the next major version`,\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 /* istanbul ignore next */\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","contextSharing","window","__VUE_QUERY_CONTEXT__","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","noop","clientPersister","isRestoring","value","unmount","promise","then","process","env","NODE_ENV","getLogger","error","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","$root","setupDevtools","provide"],"mappings":";;;;;;AAiCO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAWC,OAA8B,GAAG,EAA5C,KAAmD;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAT,CAA9B,CAAA;AACA,IAAA,IAAIC,MAAJ,CAAA;;AAEA,IAAA,IAAI,iBAAiBJ,OAAjB,IAA4BA,OAAO,CAACK,WAAxC,EAAqD;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAjB,CAAA;AACD,KAFD,MAEO;MACL,IAAIL,OAAO,CAACM,cAAR,IAA0B,OAAOC,MAAP,KAAkB,WAAhD,EAA6D;AAC3D,QAAA,IAAI,CAACA,MAAM,CAACC,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAA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AAA;AACF,KAAA;AACF,GAAA;AA7F2B;;;;"}
@@ -37,7 +37,7 @@
37
37
  // TYPES
38
38
  // UTILS
39
39
  const isServer = typeof window === 'undefined' || 'Deno' in window;
40
- function noop() {
40
+ function noop$1() {
41
41
  return undefined;
42
42
  }
43
43
  function functionalUpdate(updater, input) {
@@ -47,7 +47,7 @@
47
47
  return typeof value === 'number' && value >= 0 && value !== Infinity;
48
48
  }
49
49
  function difference(array1, array2) {
50
- return array1.filter(x => array2.indexOf(x) === -1);
50
+ return array1.filter(x => !array2.includes(x));
51
51
  }
52
52
  function replaceAt(array, index, value) {
53
53
  const copy = array.slice(0);
@@ -870,7 +870,7 @@
870
870
 
871
871
  const promise = this.promise;
872
872
  (_this$retryer = this.retryer) == null ? void 0 : _this$retryer.cancel(options);
873
- return promise ? promise.then(noop).catch(noop) : Promise.resolve();
873
+ return promise ? promise.then(noop$1).catch(noop$1) : Promise.resolve();
874
874
  }
875
875
 
876
876
  destroy() {
@@ -932,7 +932,7 @@
932
932
  }
933
933
 
934
934
  addObserver(observer) {
935
- if (this.observers.indexOf(observer) === -1) {
935
+ if (!this.observers.includes(observer)) {
936
936
  this.observers.push(observer); // Stop the query from being garbage collected
937
937
 
938
938
  this.clearGcTimeout();
@@ -945,7 +945,7 @@
945
945
  }
946
946
 
947
947
  removeObserver(observer) {
948
- if (this.observers.indexOf(observer) !== -1) {
948
+ if (this.observers.includes(observer)) {
949
949
  this.observers = this.observers.filter(x => x !== observer);
950
950
 
951
951
  if (!this.observers.length) {
@@ -1430,7 +1430,7 @@
1430
1430
  }
1431
1431
 
1432
1432
  addObserver(observer) {
1433
- if (this.observers.indexOf(observer) === -1) {
1433
+ if (!this.observers.includes(observer)) {
1434
1434
  this.observers.push(observer); // Stop the mutation from being garbage collected
1435
1435
 
1436
1436
  this.clearGcTimeout();
@@ -1728,7 +1728,7 @@
1728
1728
 
1729
1729
  this.resuming = ((_this$resuming = this.resuming) != null ? _this$resuming : Promise.resolve()).then(() => {
1730
1730
  const pausedMutations = this.mutations.filter(x => x.state.isPaused);
1731
- return notifyManager.batch(() => pausedMutations.reduce((promise, mutation) => promise.then(() => mutation.continue().catch(noop)), Promise.resolve()));
1731
+ return notifyManager.batch(() => pausedMutations.reduce((promise, mutation) => promise.then(() => mutation.continue().catch(noop$1)), Promise.resolve()));
1732
1732
  }).then(() => {
1733
1733
  this.resuming = undefined;
1734
1734
  });
@@ -2020,7 +2020,7 @@
2020
2020
  }
2021
2021
 
2022
2022
  const promises = notifyManager.batch(() => this.queryCache.findAll(filters).map(query => query.cancel(cancelOptions)));
2023
- return Promise.all(promises).then(noop).catch(noop);
2023
+ return Promise.all(promises).then(noop$1).catch(noop$1);
2024
2024
  }
2025
2025
 
2026
2026
  invalidateQueries(arg1, arg2, arg3) {
@@ -2055,10 +2055,10 @@
2055
2055
  }
2056
2056
  });
2057
2057
  }));
2058
- let promise = Promise.all(promises).then(noop);
2058
+ let promise = Promise.all(promises).then(noop$1);
2059
2059
 
2060
2060
  if (!(options != null && options.throwOnError)) {
2061
- promise = promise.catch(noop);
2061
+ promise = promise.catch(noop$1);
2062
2062
  }
2063
2063
 
2064
2064
  return promise;
@@ -2077,7 +2077,7 @@
2077
2077
  }
2078
2078
 
2079
2079
  prefetchQuery(arg1, arg2, arg3) {
2080
- return this.fetchQuery(arg1, arg2, arg3).then(noop).catch(noop);
2080
+ return this.fetchQuery(arg1, arg2, arg3).then(noop$1).catch(noop$1);
2081
2081
  }
2082
2082
 
2083
2083
  fetchInfiniteQuery(arg1, arg2, arg3) {
@@ -2087,7 +2087,7 @@
2087
2087
  }
2088
2088
 
2089
2089
  prefetchInfiniteQuery(arg1, arg2, arg3) {
2090
- return this.fetchInfiniteQuery(arg1, arg2, arg3).then(noop).catch(noop);
2090
+ return this.fetchInfiniteQuery(arg1, arg2, arg3).then(noop$1).catch(noop$1);
2091
2091
  }
2092
2092
 
2093
2093
  resumePausedMutations() {
@@ -2390,7 +2390,7 @@
2390
2390
  let promise = this.currentQuery.fetch(this.options, fetchOptions);
2391
2391
 
2392
2392
  if (!(fetchOptions != null && fetchOptions.throwOnError)) {
2393
- promise = promise.catch(noop);
2393
+ promise = promise.catch(noop$1);
2394
2394
  }
2395
2395
 
2396
2396
  return promise;
@@ -3260,6 +3260,10 @@
3260
3260
  return prototype === null || prototype === Object.prototype;
3261
3261
  }
3262
3262
 
3263
+ function noop() {
3264
+ return undefined;
3265
+ }
3266
+
3263
3267
  function useQueryClient(id = '') {
3264
3268
  var _getCurrentInstance;
3265
3269
 
@@ -4654,8 +4658,7 @@
4654
4658
  client.mount();
4655
4659
  }
4656
4660
 
4657
- let persisterUnmount = () => {// noop
4658
- };
4661
+ let persisterUnmount = noop;
4659
4662
 
4660
4663
  if (options.clientPersister) {
4661
4664
  client.isRestoring.value = true;
@@ -4732,15 +4735,17 @@
4732
4735
  });
4733
4736
  const observer = new Observer(queryClient, defaultedOptions.value);
4734
4737
  const state = vueDemi.reactive(observer.getCurrentResult());
4735
- const unsubscribe = vueDemi.ref(() => {// noop
4736
- });
4738
+ const unsubscribe = vueDemi.ref(noop);
4737
4739
  vueDemi.watch(queryClient.isRestoring, isRestoring => {
4738
4740
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
4739
4741
  if (!isRestoring) {
4740
- unsubscribe.value();
4741
- unsubscribe.value = observer.subscribe(result => {
4742
- updateState(state, result);
4743
- });
4742
+ unsubscribe.value(); // Nuxt2 memory leak fix - do not subscribe on server
4743
+
4744
+ if (!isServer) {
4745
+ unsubscribe.value = observer.subscribe(result => {
4746
+ updateState(state, result);
4747
+ });
4748
+ }
4744
4749
  }
4745
4750
  }, {
4746
4751
  immediate: true
@@ -4757,8 +4762,7 @@
4757
4762
 
4758
4763
  const suspense = () => {
4759
4764
  return new Promise(resolve => {
4760
- let stopWatch = () => {//noop
4761
- };
4765
+ let stopWatch = noop;
4762
4766
 
4763
4767
  const run = () => {
4764
4768
  if (defaultedOptions.value.enabled !== false) {
@@ -4838,14 +4842,17 @@
4838
4842
  }));
4839
4843
  const observer = new QueriesObserver(queryClient, defaultedQueries.value);
4840
4844
  const state = vueDemi.reactive(observer.getCurrentResult());
4841
- const unsubscribe = vueDemi.ref(() => {// noop
4842
- });
4845
+ const unsubscribe = vueDemi.ref(noop);
4843
4846
  vueDemi.watch(queryClient.isRestoring, isRestoring => {
4844
4847
  if (!isRestoring) {
4845
- unsubscribe.value();
4846
- unsubscribe.value = observer.subscribe(result => {
4847
- state.splice(0, result.length, ...result);
4848
- }); // Subscription would not fire for persisted results
4848
+ unsubscribe.value(); // Nuxt2 memory leak fix - do not subscribe on server
4849
+
4850
+ if (!isServer) {
4851
+ unsubscribe.value = observer.subscribe(result => {
4852
+ state.splice(0, result.length, ...result);
4853
+ });
4854
+ } // Subscription would not fire for persisted results
4855
+
4849
4856
 
4850
4857
  state.splice(0, state.length, ...observer.getOptimisticResult(defaultedQueries.value));
4851
4858
  }
@@ -4882,8 +4889,9 @@
4882
4889
  });
4883
4890
  const queryClient = (_options$value$queryC = options.value.queryClient) != null ? _options$value$queryC : useQueryClient(options.value.queryClientKey);
4884
4891
  const observer = new MutationObserver(queryClient, queryClient.defaultMutationOptions(options.value));
4885
- const state = vueDemi.reactive(observer.getCurrentResult());
4886
- const unsubscribe = observer.subscribe(result => {
4892
+ const state = vueDemi.reactive(observer.getCurrentResult()); // Nuxt2 memory leak fix - do not subscribe on server
4893
+
4894
+ const unsubscribe = isServer ? noop : observer.subscribe(result => {
4887
4895
  updateState(state, result);
4888
4896
  });
4889
4897
 
@@ -4940,8 +4948,9 @@
4940
4948
 
4941
4949
  const filters = vueDemi.computed(() => parseFilterArgs$1(arg1, arg2));
4942
4950
  const queryClient = (_filters$value$queryC = filters.value.queryClient) != null ? _filters$value$queryC : useQueryClient(filters.value.queryClientKey);
4943
- const isFetching = vueDemi.ref(queryClient.isFetching(filters));
4944
- const unsubscribe = queryClient.getQueryCache().subscribe(() => {
4951
+ const isFetching = vueDemi.ref(queryClient.isFetching(filters)); // Nuxt2 memory leak fix - do not subscribe on server
4952
+
4953
+ const unsubscribe = isServer ? noop : queryClient.getQueryCache().subscribe(() => {
4945
4954
  isFetching.value = queryClient.isFetching(filters);
4946
4955
  });
4947
4956
  vueDemi.watch(filters, () => {
@@ -4976,8 +4985,9 @@
4976
4985
 
4977
4986
  const filters = vueDemi.computed(() => parseFilterArgs(arg1, arg2));
4978
4987
  const queryClient = (_filters$value$queryC = filters.value.queryClient) != null ? _filters$value$queryC : useQueryClient(filters.value.queryClientKey);
4979
- const isMutating = vueDemi.ref(queryClient.isMutating(filters));
4980
- const unsubscribe = queryClient.getMutationCache().subscribe(() => {
4988
+ const isMutating = vueDemi.ref(queryClient.isMutating(filters)); // Nuxt2 memory leak fix - do not subscribe on server
4989
+
4990
+ const unsubscribe = isServer ? noop : queryClient.getMutationCache().subscribe(() => {
4981
4991
  isMutating.value = queryClient.isMutating(filters);
4982
4992
  });
4983
4993
  vueDemi.watch(filters, () => {