@tanstack/vue-query 4.13.5 → 4.14.1
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/README.md +2 -2
- package/build/lib/vueQueryPlugin.esm.js +4 -0
- package/build/lib/vueQueryPlugin.esm.js.map +1 -1
- package/build/lib/vueQueryPlugin.js +4 -0
- package/build/lib/vueQueryPlugin.js.map +1 -1
- package/build/lib/vueQueryPlugin.mjs +4 -0
- package/build/lib/vueQueryPlugin.mjs.map +1 -1
- package/build/umd/index.development.js +15 -3
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Visit https://tanstack.com/query/v4/docs/adapters/vue-query
|
|
|
64
64
|
export default defineComponent({
|
|
65
65
|
name: "MyComponent",
|
|
66
66
|
setup() {
|
|
67
|
-
const query = useQuery(["todos"], getTodos);
|
|
67
|
+
const query = useQuery({ queryKey: ["todos"], queryFn: getTodos });
|
|
68
68
|
|
|
69
69
|
return {
|
|
70
70
|
query,
|
|
@@ -79,5 +79,5 @@ Visit https://tanstack.com/query/v4/docs/adapters/vue-query
|
|
|
79
79
|
const id = ref(1);
|
|
80
80
|
const enabled = ref(false);
|
|
81
81
|
|
|
82
|
-
const query = useQuery(["todos", id], () => getTodos(id),
|
|
82
|
+
const query = useQuery({ queyKey: ["todos", id], queryFn: () => getTodos(id), enabled });
|
|
83
83
|
```
|
|
@@ -27,6 +27,10 @@ const VueQueryPlugin = {
|
|
|
27
27
|
|
|
28
28
|
client.mount();
|
|
29
29
|
|
|
30
|
+
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
31
|
+
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
const cleanup = () => {
|
|
31
35
|
client.unmount();
|
|
32
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.esm.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\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\nexport interface AdditionalClient {\n queryClient: QueryClient\n queryClientKey: string\n}\n\ninterface ConfigOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n queryClientKey?: string\n contextSharing?: boolean\n}\n\ninterface ClientOptions {\n queryClient?: QueryClient\n queryClientKey?: string\n contextSharing?: boolean\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 client.mount()\n\n const cleanup = () => {\n client.unmount()\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","mount","cleanup","unmount","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.esm.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\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\nexport interface AdditionalClient {\n queryClient: QueryClient\n queryClientKey: string\n}\n\ninterface ConfigOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n queryClientKey?: string\n contextSharing?: boolean\n}\n\ninterface ClientOptions {\n queryClient?: QueryClient\n queryClientKey?: string\n contextSharing?: boolean\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 client.mount()\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 }\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","mount","process","env","NODE_ENV","getLogger","error","cleanup","unmount","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;A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|
client.mount();
|
|
33
33
|
|
|
34
|
+
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
35
|
+
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
const cleanup = () => {
|
|
35
39
|
client.unmount();
|
|
36
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\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\nexport interface AdditionalClient {\n queryClient: QueryClient\n queryClientKey: string\n}\n\ninterface ConfigOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n queryClientKey?: string\n contextSharing?: boolean\n}\n\ninterface ClientOptions {\n queryClient?: QueryClient\n queryClientKey?: string\n contextSharing?: boolean\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 client.mount()\n\n const cleanup = () => {\n client.unmount()\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","mount","cleanup","unmount","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\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\nexport interface AdditionalClient {\n queryClient: QueryClient\n queryClientKey: string\n}\n\ninterface ConfigOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n queryClientKey?: string\n contextSharing?: boolean\n}\n\ninterface ClientOptions {\n queryClient?: QueryClient\n queryClientKey?: string\n contextSharing?: boolean\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 client.mount()\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 }\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","mount","process","env","NODE_ENV","getLogger","error","cleanup","unmount","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty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U,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CoB,QAAAA,sBAAa,CAACrC,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA/E2B;;;;"}
|
|
@@ -27,6 +27,10 @@ const VueQueryPlugin = {
|
|
|
27
27
|
|
|
28
28
|
client.mount();
|
|
29
29
|
|
|
30
|
+
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
31
|
+
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
const cleanup = () => {
|
|
31
35
|
client.unmount();
|
|
32
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.mjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\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\nexport interface AdditionalClient {\n queryClient: QueryClient\n queryClientKey: string\n}\n\ninterface ConfigOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n queryClientKey?: string\n contextSharing?: boolean\n}\n\ninterface ClientOptions {\n queryClient?: QueryClient\n queryClientKey?: string\n contextSharing?: boolean\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 client.mount()\n\n const cleanup = () => {\n client.unmount()\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","mount","cleanup","unmount","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.mjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\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\nexport interface AdditionalClient {\n queryClient: QueryClient\n queryClientKey: string\n}\n\ninterface ConfigOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n queryClientKey?: string\n contextSharing?: boolean\n}\n\ninterface ClientOptions {\n queryClient?: QueryClient\n queryClientKey?: string\n contextSharing?: boolean\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 client.mount()\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 }\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","mount","process","env","NODE_ENV","getLogger","error","cleanup","unmount","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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ACvBC,cAAAA,aAAa,CAAC,IAAD,EAAOhC,MAAP,CAAb,CAAA;AACD,aAAA;AACF,WAAA;AACF,SAAA;;OAlBH,CAAA,CAAA;AAoBD,KArBD,MAqBO;AACLL,MAAAA,GAAG,CAACsC,OAAJ,CAAYpC,SAAZ,EAAuBG,MAAvB,CAAA,CAAA;;AAEA,MAAA,IAAIU,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA7B,EAA4C;AAC1CoB,QAAAA,aAAa,CAACrC,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA/E2B;;;;"}
|
|
@@ -1232,9 +1232,8 @@
|
|
|
1232
1232
|
|
|
1233
1233
|
function getDefaultState$1(options) {
|
|
1234
1234
|
const data = typeof options.initialData === 'function' ? options.initialData() : options.initialData;
|
|
1235
|
-
const hasInitialData = typeof options.initialData !== 'undefined';
|
|
1236
|
-
const initialDataUpdatedAt = hasInitialData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1237
1235
|
const hasData = typeof data !== 'undefined';
|
|
1236
|
+
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1238
1237
|
return {
|
|
1239
1238
|
data,
|
|
1240
1239
|
dataUpdateCount: 0,
|
|
@@ -1842,6 +1841,10 @@
|
|
|
1842
1841
|
this.defaultOptions = config.defaultOptions || {};
|
|
1843
1842
|
this.queryDefaults = [];
|
|
1844
1843
|
this.mutationDefaults = [];
|
|
1844
|
+
|
|
1845
|
+
if (config.logger) {
|
|
1846
|
+
this.logger.error("Passing a custom logger has been deprecated and will be removed in the next major version.");
|
|
1847
|
+
}
|
|
1845
1848
|
}
|
|
1846
1849
|
|
|
1847
1850
|
mount() {
|
|
@@ -2215,6 +2218,10 @@
|
|
|
2215
2218
|
const prevQuery = this.currentQuery;
|
|
2216
2219
|
this.options = this.client.defaultQueryOptions(options);
|
|
2217
2220
|
|
|
2221
|
+
if (typeof (options == null ? void 0 : options.isDataEqual) !== 'undefined') {
|
|
2222
|
+
this.client.getLogger().error("The isDataEqual option has been deprecated and will be removed in the next major version. You can achieve the same functionality by passing a function as the structuralSharing option");
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2218
2225
|
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2219
2226
|
this.client.getQueryCache().notify({
|
|
2220
2227
|
type: 'observerOptionsUpdated',
|
|
@@ -2427,7 +2434,7 @@
|
|
|
2427
2434
|
} // Keep previous data if needed
|
|
2428
2435
|
|
|
2429
2436
|
|
|
2430
|
-
if (options.keepPreviousData && !state.
|
|
2437
|
+
if (options.keepPreviousData && !state.dataUpdatedAt && prevQueryResult != null && prevQueryResult.isSuccess && status !== 'error') {
|
|
2431
2438
|
data = prevQueryResult.data;
|
|
2432
2439
|
dataUpdatedAt = prevQueryResult.dataUpdatedAt;
|
|
2433
2440
|
status = prevQueryResult.status;
|
|
@@ -4556,6 +4563,10 @@
|
|
|
4556
4563
|
|
|
4557
4564
|
client.mount();
|
|
4558
4565
|
|
|
4566
|
+
if (options.contextSharing) {
|
|
4567
|
+
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4559
4570
|
const cleanup = () => {
|
|
4560
4571
|
client.unmount();
|
|
4561
4572
|
};
|
|
@@ -4882,6 +4893,7 @@
|
|
|
4882
4893
|
exports.parseMutationArgs = parseMutationArgs$1;
|
|
4883
4894
|
exports.parseMutationFilterArgs = parseMutationFilterArgs$1;
|
|
4884
4895
|
exports.parseQueryArgs = parseQueryArgs;
|
|
4896
|
+
exports.replaceEqualDeep = replaceEqualDeep;
|
|
4885
4897
|
exports.useInfiniteQuery = useInfiniteQuery;
|
|
4886
4898
|
exports.useIsFetching = useIsFetching;
|
|
4887
4899
|
exports.useIsMutating = useIsMutating;
|