@tanstack/vue-query 4.24.9 → 5.0.0-alpha.0
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/__mocks__/useBaseQuery.d.ts +2 -2
- package/build/lib/__mocks__/useQueryClient.d.ts +1 -1
- package/build/lib/devtools/devtools.esm.js +6 -12
- package/build/lib/devtools/devtools.esm.js.map +1 -1
- package/build/lib/devtools/devtools.js +6 -14
- package/build/lib/devtools/devtools.js.map +1 -1
- package/build/lib/devtools/devtools.mjs +6 -12
- package/build/lib/devtools/devtools.mjs.map +1 -1
- package/build/lib/devtools/utils.esm.js +0 -23
- package/build/lib/devtools/utils.esm.js.map +1 -1
- package/build/lib/devtools/utils.js +0 -25
- package/build/lib/devtools/utils.js.map +1 -1
- package/build/lib/devtools/utils.mjs +0 -23
- package/build/lib/devtools/utils.mjs.map +1 -1
- package/build/lib/index.js +0 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/mutationCache.d.ts +3 -3
- package/build/lib/mutationCache.esm.js +1 -3
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js +1 -5
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationCache.mjs +1 -3
- package/build/lib/mutationCache.mjs.map +1 -1
- package/build/lib/queryCache.d.ts +2 -4
- package/build/lib/queryCache.esm.js +5 -16
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js +4 -17
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryCache.mjs +5 -16
- package/build/lib/queryCache.mjs.map +1 -1
- package/build/lib/queryClient.d.ts +13 -29
- package/build/lib/queryClient.esm.js +33 -124
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +32 -125
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs +33 -124
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/types.d.ts +1 -13
- package/build/lib/useBaseQuery.d.ts +6 -7
- package/build/lib/useBaseQuery.esm.js +15 -41
- package/build/lib/useBaseQuery.esm.js.map +1 -1
- package/build/lib/useBaseQuery.js +12 -41
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.mjs +15 -41
- package/build/lib/useBaseQuery.mjs.map +1 -1
- package/build/lib/useInfiniteQuery.d.ts +10 -10
- package/build/lib/useInfiniteQuery.esm.js +5 -5
- package/build/lib/useInfiniteQuery.esm.js.map +1 -1
- package/build/lib/useInfiniteQuery.js +5 -7
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useInfiniteQuery.mjs +5 -5
- package/build/lib/useInfiniteQuery.mjs.map +1 -1
- package/build/lib/useIsFetching.d.ts +5 -6
- package/build/lib/useIsFetching.esm.js +10 -28
- package/build/lib/useIsFetching.esm.js.map +1 -1
- package/build/lib/useIsFetching.js +7 -28
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.mjs +10 -28
- package/build/lib/useIsFetching.mjs.map +1 -1
- package/build/lib/useIsMutating.d.ts +5 -6
- package/build/lib/useIsMutating.esm.js +10 -28
- package/build/lib/useIsMutating.esm.js.map +1 -1
- package/build/lib/useIsMutating.js +7 -28
- package/build/lib/useIsMutating.js.map +1 -1
- package/build/lib/useIsMutating.mjs +10 -28
- package/build/lib/useIsMutating.mjs.map +1 -1
- package/build/lib/useMutation.d.ts +6 -12
- package/build/lib/useMutation.esm.js +12 -41
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +9 -41
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +12 -41
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/useQueries.d.ts +15 -10
- package/build/lib/useQueries.esm.js +17 -26
- package/build/lib/useQueries.esm.js.map +1 -1
- package/build/lib/useQueries.js +16 -27
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.mjs +17 -26
- package/build/lib/useQueries.mjs.map +1 -1
- package/build/lib/useQuery.d.ts +14 -28
- package/build/lib/useQuery.esm.js +5 -5
- package/build/lib/useQuery.esm.js.map +1 -1
- package/build/lib/useQuery.js +5 -7
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/useQuery.mjs +5 -5
- package/build/lib/useQuery.mjs.map +1 -1
- package/build/lib/useQueryClient.esm.js +1 -7
- package/build/lib/useQueryClient.esm.js.map +1 -1
- package/build/lib/useQueryClient.js +1 -9
- package/build/lib/useQueryClient.js.map +1 -1
- package/build/lib/useQueryClient.mjs +1 -7
- package/build/lib/useQueryClient.mjs.map +1 -1
- package/build/lib/utils.d.ts +3 -6
- package/build/lib/utils.esm.js +9 -17
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +8 -20
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +9 -17
- package/build/lib/utils.mjs.map +1 -1
- package/build/lib/vueQueryPlugin.d.ts +0 -6
- package/build/lib/vueQueryPlugin.esm.js +9 -31
- package/build/lib/vueQueryPlugin.esm.js.map +1 -1
- package/build/lib/vueQueryPlugin.js +9 -33
- package/build/lib/vueQueryPlugin.js.map +1 -1
- package/build/lib/vueQueryPlugin.mjs +9 -31
- package/build/lib/vueQueryPlugin.mjs.map +1 -1
- package/build/umd/index.development.js +1033 -1858
- 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 +11 -7
|
@@ -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\
|
|
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\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* 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","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAE,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,WAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,QAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAG,MAAM;AAC3B;KACD,CAAA;IAED,IAAIZ,OAAO,CAACa,eAAe,EAAE;AAC3BT,MAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGjB,OAAO,CAACa,eAAe,CAACT,MAAM,CAAC,CAAA;AAC1DQ,MAAAA,gBAAgB,GAAGI,OAAO,CAAA;MAC1BC,OAAO,CAAC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,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,MAAM;AACLL,MAAAA,GAAG,CAACwC,OAAO,CAACtC,SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,aAAa,CAACvC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var vueDemi = require('vue-demi');
|
|
4
|
+
var queryCore = require('@tanstack/query-core');
|
|
6
5
|
var queryClient = require('./queryClient.js');
|
|
7
6
|
var utils = require('./utils.js');
|
|
8
7
|
var devtools = require('./devtools/devtools.js');
|
|
@@ -11,29 +10,18 @@ const VueQueryPlugin = {
|
|
|
11
10
|
install: (app, options = {}) => {
|
|
12
11
|
const clientKey = utils.getClientKey(options.queryClientKey);
|
|
13
12
|
let client;
|
|
14
|
-
|
|
15
13
|
if ('queryClient' in options && options.queryClient) {
|
|
16
14
|
client = options.queryClient;
|
|
17
15
|
} else {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
21
|
-
client = new queryClient.QueryClient(clientConfig);
|
|
22
|
-
window.__VUE_QUERY_CONTEXT__ = client;
|
|
23
|
-
} else {
|
|
24
|
-
client = window.__VUE_QUERY_CONTEXT__;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
28
|
-
client = new queryClient.QueryClient(clientConfig);
|
|
29
|
-
}
|
|
16
|
+
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
17
|
+
client = new queryClient.QueryClient(clientConfig);
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let persisterUnmount = () => {
|
|
19
|
+
if (!queryCore.isServer) {
|
|
20
|
+
client.mount();
|
|
21
|
+
}
|
|
22
|
+
let persisterUnmount = () => {
|
|
23
|
+
// noop
|
|
35
24
|
};
|
|
36
|
-
|
|
37
25
|
if (options.clientPersister) {
|
|
38
26
|
client.isRestoring.value = true;
|
|
39
27
|
const [unmount, promise] = options.clientPersister(client);
|
|
@@ -42,29 +30,21 @@ const VueQueryPlugin = {
|
|
|
42
30
|
client.isRestoring.value = false;
|
|
43
31
|
});
|
|
44
32
|
}
|
|
45
|
-
|
|
46
|
-
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
47
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
33
|
const cleanup = () => {
|
|
51
34
|
client.unmount();
|
|
52
35
|
persisterUnmount();
|
|
53
36
|
};
|
|
54
|
-
|
|
55
37
|
if (app.onUnmount) {
|
|
56
38
|
app.onUnmount(cleanup);
|
|
57
39
|
} else {
|
|
58
40
|
const originalUnmount = app.unmount;
|
|
59
|
-
|
|
60
41
|
app.unmount = function vueQueryUnmount() {
|
|
61
42
|
cleanup();
|
|
62
43
|
originalUnmount();
|
|
63
44
|
};
|
|
64
45
|
}
|
|
65
|
-
/* istanbul ignore next */
|
|
66
|
-
|
|
67
46
|
|
|
47
|
+
/* istanbul ignore next */
|
|
68
48
|
if (vueDemi.isVue2) {
|
|
69
49
|
app.mixin({
|
|
70
50
|
beforeCreate() {
|
|
@@ -76,20 +56,16 @@ const VueQueryPlugin = {
|
|
|
76
56
|
set: v => Object.assign(provideCache, v)
|
|
77
57
|
});
|
|
78
58
|
}
|
|
79
|
-
|
|
80
59
|
this._provided[clientKey] = client;
|
|
81
|
-
|
|
82
60
|
if (process.env.NODE_ENV === 'development') {
|
|
83
61
|
if (this === this.$root) {
|
|
84
62
|
devtools.setupDevtools(this, client);
|
|
85
63
|
}
|
|
86
64
|
}
|
|
87
65
|
}
|
|
88
|
-
|
|
89
66
|
});
|
|
90
67
|
} else {
|
|
91
68
|
app.provide(clientKey, client);
|
|
92
|
-
|
|
93
69
|
if (process.env.NODE_ENV === 'development') {
|
|
94
70
|
devtools.setupDevtools(app, client);
|
|
95
71
|
}
|
|
@@ -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\
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\nimport type { QueryClientConfig } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { MaybeRefDeep } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* 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","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAE,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,kBAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;A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AACA,UAAA,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;YACnB,MAAMC,YAAY,GAAG,EAAE,CAAA;AACvBC,YAAAA,MAAM,CAACC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE;cACvCC,GAAG,EAAE,MAAMH,YAAY;cACvBI,GAAG,EAAGC,CAAC,IAAKJ,MAAM,CAACK,MAAM,CAACN,YAAY,EAAEK,CAAC,CAAA;AAC3C,aAAC,CAAC,CAAA;AACJ,WAAA;AAEA,UAAA,IAAI,CAACN,SAAS,CAACzB,SAAS,CAAC,GAAGG,MAAM,CAAA;AAElC,UAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1C,YAAA,IAAI,IAAI,KAAK,IAAI,CAACC,KAAK,EAAE;AACvBC,cAAAA,sBAAa,CAAC,IAAI,EAAElC,MAAM,CAAC,CAAA;AAC7B,aAAA;AACF,WAAA;AACF,SAAA;AACF,OAAC,CAAC,CAAA;AACJ,KAAC,MAAM;AACLL,MAAAA,GAAG,CAACwC,OAAO,CAACtC,SAAS,EAAEG,MAAM,CAAC,CAAA;AAE9B,MAAA,IAAI8B,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,EAAE;AAC1CE,QAAAA,sBAAa,CAACvC,GAAG,EAAEK,MAAM,CAAC,CAAA;AAC5B,OAAA;AACF,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -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';
|
|
@@ -7,29 +8,18 @@ const VueQueryPlugin = {
|
|
|
7
8
|
install: (app, options = {}) => {
|
|
8
9
|
const clientKey = getClientKey(options.queryClientKey);
|
|
9
10
|
let client;
|
|
10
|
-
|
|
11
11
|
if ('queryClient' in options && options.queryClient) {
|
|
12
12
|
client = options.queryClient;
|
|
13
13
|
} else {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
17
|
-
client = new QueryClient(clientConfig);
|
|
18
|
-
window.__VUE_QUERY_CONTEXT__ = client;
|
|
19
|
-
} else {
|
|
20
|
-
client = window.__VUE_QUERY_CONTEXT__;
|
|
21
|
-
}
|
|
22
|
-
} else {
|
|
23
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
24
|
-
client = new QueryClient(clientConfig);
|
|
25
|
-
}
|
|
14
|
+
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
15
|
+
client = new QueryClient(clientConfig);
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let persisterUnmount = () => {
|
|
17
|
+
if (!isServer) {
|
|
18
|
+
client.mount();
|
|
19
|
+
}
|
|
20
|
+
let persisterUnmount = () => {
|
|
21
|
+
// noop
|
|
31
22
|
};
|
|
32
|
-
|
|
33
23
|
if (options.clientPersister) {
|
|
34
24
|
client.isRestoring.value = true;
|
|
35
25
|
const [unmount, promise] = options.clientPersister(client);
|
|
@@ -38,29 +28,21 @@ const VueQueryPlugin = {
|
|
|
38
28
|
client.isRestoring.value = false;
|
|
39
29
|
});
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
43
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
31
|
const cleanup = () => {
|
|
47
32
|
client.unmount();
|
|
48
33
|
persisterUnmount();
|
|
49
34
|
};
|
|
50
|
-
|
|
51
35
|
if (app.onUnmount) {
|
|
52
36
|
app.onUnmount(cleanup);
|
|
53
37
|
} else {
|
|
54
38
|
const originalUnmount = app.unmount;
|
|
55
|
-
|
|
56
39
|
app.unmount = function vueQueryUnmount() {
|
|
57
40
|
cleanup();
|
|
58
41
|
originalUnmount();
|
|
59
42
|
};
|
|
60
43
|
}
|
|
61
|
-
/* istanbul ignore next */
|
|
62
|
-
|
|
63
44
|
|
|
45
|
+
/* istanbul ignore next */
|
|
64
46
|
if (isVue2) {
|
|
65
47
|
app.mixin({
|
|
66
48
|
beforeCreate() {
|
|
@@ -72,20 +54,16 @@ const VueQueryPlugin = {
|
|
|
72
54
|
set: v => Object.assign(provideCache, v)
|
|
73
55
|
});
|
|
74
56
|
}
|
|
75
|
-
|
|
76
57
|
this._provided[clientKey] = client;
|
|
77
|
-
|
|
78
58
|
if (process.env.NODE_ENV === 'development') {
|
|
79
59
|
if (this === this.$root) {
|
|
80
60
|
setupDevtools(this, client);
|
|
81
61
|
}
|
|
82
62
|
}
|
|
83
63
|
}
|
|
84
|
-
|
|
85
64
|
});
|
|
86
65
|
} else {
|
|
87
66
|
app.provide(clientKey, client);
|
|
88
|
-
|
|
89
67
|
if (process.env.NODE_ENV === 'development') {
|
|
90
68
|
setupDevtools(app, client);
|
|
91
69
|
}
|
|
@@ -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\
|
|
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\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n queryClientKey?: string\n clientPersister?: ClientPersister\n}\n\ninterface ConfigOptions extends CommonOptions {\n queryClientConfig?: MaybeRefDeep<QueryClientConfig>\n}\n\ninterface ClientOptions extends CommonOptions {\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!isServer) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n client.isRestoring.value = true\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n client.isRestoring.value = false\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n /* 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","clientConfig","queryClientConfig","undefined","QueryClient","isServer","mount","persisterUnmount","clientPersister","isRestoring","value","unmount","promise","then","cleanup","onUnmount","originalUnmount","vueQueryUnmount","isVue2","mixin","beforeCreate","_provided","provideCache","Object","defineProperty","get","set","v","assign","process","env","NODE_ENV","$root","setupDevtools","provide"],"mappings":";;;;;;AA0BO,MAAMA,cAAc,GAAG;EAC5BC,OAAO,EAAE,CAACC,GAAQ,EAAEC,OAA8B,GAAG,EAAE,KAAK;AAC1D,IAAA,MAAMC,SAAS,GAAGC,YAAY,CAACF,OAAO,CAACG,cAAc,CAAC,CAAA;AACtD,IAAA,IAAIC,MAAmB,CAAA;AAEvB,IAAA,IAAI,aAAa,IAAIJ,OAAO,IAAIA,OAAO,CAACK,WAAW,EAAE;MACnDD,MAAM,GAAGJ,OAAO,CAACK,WAAW,CAAA;AAC9B,KAAC,MAAM;MACL,MAAMC,YAAY,GAChB,mBAAmB,IAAIN,OAAO,GAAGA,OAAO,CAACO,iBAAiB,GAAGC,SAAS,CAAA;AACxEJ,MAAAA,MAAM,GAAG,IAAIK,WAAW,CAACH,YAAY,CAAC,CAAA;AACxC,KAAA;IAEA,IAAI,CAACI,QAAQ,EAAE;MACbN,MAAM,CAACO,KAAK,EAAE,CAAA;AAChB,KAAA;IAEA,IAAIC,gBAAgB,GAAG,MAAM;AAC3B;KACD,CAAA;IAED,IAAIZ,OAAO,CAACa,eAAe,EAAE;AAC3BT,MAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,IAAI,CAAA;MAC/B,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,GAAGjB,OAAO,CAACa,eAAe,CAACT,MAAM,CAAC,CAAA;AAC1DQ,MAAAA,gBAAgB,GAAGI,OAAO,CAAA;MAC1BC,OAAO,CAACC,IAAI,CAAC,MAAM;AACjBd,QAAAA,MAAM,CAACU,WAAW,CAACC,KAAK,GAAG,KAAK,CAAA;AAClC,OAAC,CAAC,CAAA;AACJ,KAAA;IAEA,MAAMI,OAAO,GAAG,MAAM;MACpBf,MAAM,CAACY,OAAO,EAAE,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