@tanstack/vue-query 4.24.9 → 4.24.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/vueQueryPlugin.esm.js +4 -1
- package/build/lib/vueQueryPlugin.esm.js.map +1 -1
- package/build/lib/vueQueryPlugin.js +4 -1
- package/build/lib/vueQueryPlugin.js.map +1 -1
- package/build/lib/vueQueryPlugin.mjs +4 -1
- package/build/lib/vueQueryPlugin.mjs.map +1 -1
- package/build/umd/index.development.js +12 -5
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isVue2 } from 'vue-demi';
|
|
2
|
+
import { isServer } from '@tanstack/query-core';
|
|
2
3
|
import { QueryClient } from './queryClient.esm.js';
|
|
3
4
|
import { getClientKey } from './utils.esm.js';
|
|
4
5
|
import { setupDevtools } from './devtools/devtools.esm.js';
|
|
@@ -25,7 +26,9 @@ const VueQueryPlugin = {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
if (!isServer) {
|
|
30
|
+
client.mount();
|
|
31
|
+
}
|
|
29
32
|
|
|
30
33
|
let persisterUnmount = () => {// noop
|
|
31
34
|
};
|
|
@@ -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\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 client.mount()\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","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":"
|
|
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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,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;;;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var vueDemi = require('vue-demi');
|
|
6
|
+
var queryCore = require('@tanstack/query-core');
|
|
6
7
|
var queryClient = require('./queryClient.js');
|
|
7
8
|
var utils = require('./utils.js');
|
|
8
9
|
var devtools = require('./devtools/devtools.js');
|
|
@@ -29,7 +30,9 @@ const VueQueryPlugin = {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
if (!queryCore.isServer) {
|
|
34
|
+
client.mount();
|
|
35
|
+
}
|
|
33
36
|
|
|
34
37
|
let persisterUnmount = () => {// noop
|
|
35
38
|
};
|
|
@@ -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\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 client.mount()\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","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":"
|
|
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,qBAAZ,EAAmC;UACjC,MAAMC,YAAY,GAChB,mBAAuBT,IAAAA,OAAvB,GACIA,OAAO,CAACU,iBADZ,GAEIC,SAHN,CAAA;AAIAP,UAAAA,MAAM,GAAG,IAAIQ,uBAAJ,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,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,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,sBAAa,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,sBAAa,CAAC5C,GAAD,EAAMK,MAAN,CAAb,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;AA/F2B;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isVue2 } from 'vue-demi';
|
|
2
|
+
import { isServer } from '@tanstack/query-core';
|
|
2
3
|
import { QueryClient } from './queryClient.mjs';
|
|
3
4
|
import { getClientKey } from './utils.mjs';
|
|
4
5
|
import { setupDevtools } from './devtools/devtools.mjs';
|
|
@@ -25,7 +26,9 @@ const VueQueryPlugin = {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
if (!isServer) {
|
|
30
|
+
client.mount();
|
|
31
|
+
}
|
|
29
32
|
|
|
30
33
|
let persisterUnmount = () => {// noop
|
|
31
34
|
};
|
|
@@ -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\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 client.mount()\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","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":"
|
|
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,CA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@ -3146,11 +3146,16 @@
|
|
|
3146
3146
|
queries.forEach(dehydratedQuery => {
|
|
3147
3147
|
var _options$defaultOptio2;
|
|
3148
3148
|
|
|
3149
|
-
const query = queryCache.get(dehydratedQuery.queryHash); //
|
|
3149
|
+
const query = queryCache.get(dehydratedQuery.queryHash); // Reset fetch status to idle in the dehydrated state to avoid
|
|
3150
|
+
// query being stuck in fetching state upon hydration
|
|
3151
|
+
|
|
3152
|
+
const dehydratedQueryState = { ...dehydratedQuery.state,
|
|
3153
|
+
fetchStatus: 'idle'
|
|
3154
|
+
}; // Do not hydrate if an existing query exists with newer data
|
|
3150
3155
|
|
|
3151
3156
|
if (query) {
|
|
3152
|
-
if (query.state.dataUpdatedAt <
|
|
3153
|
-
query.setState(
|
|
3157
|
+
if (query.state.dataUpdatedAt < dehydratedQueryState.dataUpdatedAt) {
|
|
3158
|
+
query.setState(dehydratedQueryState);
|
|
3154
3159
|
}
|
|
3155
3160
|
|
|
3156
3161
|
return;
|
|
@@ -3160,7 +3165,7 @@
|
|
|
3160
3165
|
queryCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio2 = options.defaultOptions) == null ? void 0 : _options$defaultOptio2.queries),
|
|
3161
3166
|
queryKey: dehydratedQuery.queryKey,
|
|
3162
3167
|
queryHash: dehydratedQuery.queryHash
|
|
3163
|
-
},
|
|
3168
|
+
}, dehydratedQueryState);
|
|
3164
3169
|
});
|
|
3165
3170
|
}
|
|
3166
3171
|
|
|
@@ -4608,7 +4613,9 @@
|
|
|
4608
4613
|
}
|
|
4609
4614
|
}
|
|
4610
4615
|
|
|
4611
|
-
|
|
4616
|
+
if (!isServer) {
|
|
4617
|
+
client.mount();
|
|
4618
|
+
}
|
|
4612
4619
|
|
|
4613
4620
|
let persisterUnmount = () => {// noop
|
|
4614
4621
|
};
|