@tanstack/vue-query 4.37.0 → 4.39.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/README.md +13 -5
- package/build/lib/queryCache.d.ts +2 -1
- package/build/lib/useInfiniteQuery.d.ts +2 -9
- package/build/lib/useQuery.d.ts +4 -12
- package/package.json +3 -10
- package/build/lib/__mocks__/useBaseQuery.d.ts.map +0 -1
- package/build/lib/__mocks__/useQueryClient.d.ts.map +0 -1
- package/build/lib/__tests__/mutationCache.test.d.ts.map +0 -1
- package/build/lib/__tests__/queryCache.test.d.ts.map +0 -1
- package/build/lib/__tests__/queryClient.test.d.ts.map +0 -1
- package/build/lib/__tests__/test-utils.d.ts.map +0 -1
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts.map +0 -1
- package/build/lib/__tests__/useInfiniteQuery.types.test.d.ts.map +0 -1
- package/build/lib/__tests__/useIsFetching.test.d.ts.map +0 -1
- package/build/lib/__tests__/useIsMutating.test.d.ts.map +0 -1
- package/build/lib/__tests__/useMutation.test.d.ts.map +0 -1
- package/build/lib/__tests__/useMutation.types.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQueries.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQuery.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQuery.types.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQueryClient.test.d.ts.map +0 -1
- package/build/lib/__tests__/utils.test.d.ts.map +0 -1
- package/build/lib/__tests__/vueQueryPlugin.test.d.ts.map +0 -1
- package/build/lib/devtools/devtools.d.ts.map +0 -1
- package/build/lib/devtools/devtools.esm.js +0 -162
- package/build/lib/devtools/devtools.esm.js.map +0 -1
- package/build/lib/devtools/devtools.js +0 -166
- package/build/lib/devtools/devtools.js.map +0 -1
- package/build/lib/devtools/devtools.mjs +0 -162
- package/build/lib/devtools/devtools.mjs.map +0 -1
- package/build/lib/devtools/utils.d.ts.map +0 -1
- package/build/lib/devtools/utils.esm.js +0 -103
- package/build/lib/devtools/utils.esm.js.map +0 -1
- package/build/lib/devtools/utils.js +0 -111
- package/build/lib/devtools/utils.js.map +0 -1
- package/build/lib/devtools/utils.mjs +0 -103
- package/build/lib/devtools/utils.mjs.map +0 -1
- package/build/lib/index.d.ts.map +0 -1
- package/build/lib/index.esm.js +0 -14
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -39
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -14
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/mutationCache.d.ts.map +0 -1
- package/build/lib/mutationCache.esm.js +0 -16
- package/build/lib/mutationCache.esm.js.map +0 -1
- package/build/lib/mutationCache.js +0 -20
- package/build/lib/mutationCache.js.map +0 -1
- package/build/lib/mutationCache.mjs +0 -16
- package/build/lib/mutationCache.mjs.map +0 -1
- package/build/lib/queryCache.d.ts.map +0 -1
- package/build/lib/queryCache.esm.js +0 -25
- package/build/lib/queryCache.esm.js.map +0 -1
- package/build/lib/queryCache.js +0 -29
- package/build/lib/queryCache.js.map +0 -1
- package/build/lib/queryCache.mjs +0 -25
- package/build/lib/queryCache.mjs.map +0 -1
- package/build/lib/queryClient.d.ts.map +0 -1
- package/build/lib/queryClient.esm.js +0 -175
- package/build/lib/queryClient.esm.js.map +0 -1
- package/build/lib/queryClient.js +0 -179
- package/build/lib/queryClient.js.map +0 -1
- package/build/lib/queryClient.mjs +0 -175
- package/build/lib/queryClient.mjs.map +0 -1
- package/build/lib/types.d.ts.map +0 -1
- package/build/lib/useBaseQuery.d.ts.map +0 -1
- package/build/lib/useBaseQuery.esm.js +0 -125
- package/build/lib/useBaseQuery.esm.js.map +0 -1
- package/build/lib/useBaseQuery.js +0 -130
- package/build/lib/useBaseQuery.js.map +0 -1
- package/build/lib/useBaseQuery.mjs +0 -125
- package/build/lib/useBaseQuery.mjs.map +0 -1
- package/build/lib/useInfiniteQuery.d.ts.map +0 -1
- package/build/lib/useInfiniteQuery.esm.js +0 -10
- package/build/lib/useInfiniteQuery.esm.js.map +0 -1
- package/build/lib/useInfiniteQuery.js +0 -14
- package/build/lib/useInfiniteQuery.js.map +0 -1
- package/build/lib/useInfiniteQuery.mjs +0 -10
- package/build/lib/useInfiniteQuery.mjs.map +0 -1
- package/build/lib/useIsFetching.d.ts.map +0 -1
- package/build/lib/useIsFetching.esm.js +0 -47
- package/build/lib/useIsFetching.esm.js.map +0 -1
- package/build/lib/useIsFetching.js +0 -52
- package/build/lib/useIsFetching.js.map +0 -1
- package/build/lib/useIsFetching.mjs +0 -47
- package/build/lib/useIsFetching.mjs.map +0 -1
- package/build/lib/useIsMutating.d.ts.map +0 -1
- package/build/lib/useIsMutating.esm.js +0 -47
- package/build/lib/useIsMutating.esm.js.map +0 -1
- package/build/lib/useIsMutating.js +0 -52
- package/build/lib/useIsMutating.js.map +0 -1
- package/build/lib/useIsMutating.mjs +0 -47
- package/build/lib/useIsMutating.mjs.map +0 -1
- package/build/lib/useMutation.d.ts.map +0 -1
- package/build/lib/useMutation.esm.js +0 -77
- package/build/lib/useMutation.esm.js.map +0 -1
- package/build/lib/useMutation.js +0 -82
- package/build/lib/useMutation.js.map +0 -1
- package/build/lib/useMutation.mjs +0 -77
- package/build/lib/useMutation.mjs.map +0 -1
- package/build/lib/useQueries.d.ts.map +0 -1
- package/build/lib/useQueries.esm.js +0 -72
- package/build/lib/useQueries.esm.js.map +0 -1
- package/build/lib/useQueries.js +0 -76
- package/build/lib/useQueries.js.map +0 -1
- package/build/lib/useQueries.mjs +0 -72
- package/build/lib/useQueries.mjs.map +0 -1
- package/build/lib/useQuery.d.ts.map +0 -1
- package/build/lib/useQuery.esm.js +0 -10
- package/build/lib/useQuery.esm.js.map +0 -1
- package/build/lib/useQuery.js +0 -14
- package/build/lib/useQuery.js.map +0 -1
- package/build/lib/useQuery.mjs +0 -10
- package/build/lib/useQuery.mjs.map +0 -1
- package/build/lib/useQueryClient.d.ts.map +0 -1
- package/build/lib/useQueryClient.esm.js +0 -24
- package/build/lib/useQueryClient.esm.js.map +0 -1
- package/build/lib/useQueryClient.js +0 -28
- package/build/lib/useQueryClient.js.map +0 -1
- package/build/lib/useQueryClient.mjs +0 -24
- package/build/lib/useQueryClient.mjs.map +0 -1
- package/build/lib/utils.d.ts.map +0 -1
- package/build/lib/utils.esm.js +0 -67
- package/build/lib/utils.esm.js.map +0 -1
- package/build/lib/utils.js +0 -78
- package/build/lib/utils.js.map +0 -1
- package/build/lib/utils.mjs +0 -67
- package/build/lib/utils.mjs.map +0 -1
- package/build/lib/vueQueryPlugin.d.ts.map +0 -1
- package/build/lib/vueQueryPlugin.esm.js +0 -101
- package/build/lib/vueQueryPlugin.esm.js.map +0 -1
- package/build/lib/vueQueryPlugin.js +0 -105
- package/build/lib/vueQueryPlugin.js.map +0 -1
- package/build/lib/vueQueryPlugin.mjs +0 -101
- package/build/lib/vueQueryPlugin.mjs.map +0 -1
- package/build/umd/index.development.js +0 -5187
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -2
- package/build/umd/index.production.js.map +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var vueDemi = require('vue-demi');
|
|
6
|
-
var queryCore = require('@tanstack/query-core');
|
|
7
|
-
var queryClient = require('./queryClient.js');
|
|
8
|
-
var utils = require('./utils.js');
|
|
9
|
-
var devtools = require('./devtools/devtools.js');
|
|
10
|
-
|
|
11
|
-
const VueQueryPlugin = {
|
|
12
|
-
install: (app, options = {}) => {
|
|
13
|
-
const clientKey = utils.getClientKey(options.queryClientKey);
|
|
14
|
-
let client;
|
|
15
|
-
|
|
16
|
-
if ('queryClient' in options && options.queryClient) {
|
|
17
|
-
client = options.queryClient;
|
|
18
|
-
} else {
|
|
19
|
-
if (options.contextSharing && typeof window !== 'undefined') {
|
|
20
|
-
if (!window.__VUE_QUERY_CONTEXT__) {
|
|
21
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
22
|
-
client = new queryClient.QueryClient(clientConfig);
|
|
23
|
-
window.__VUE_QUERY_CONTEXT__ = client;
|
|
24
|
-
} else {
|
|
25
|
-
client = window.__VUE_QUERY_CONTEXT__;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
29
|
-
client = new queryClient.QueryClient(clientConfig);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!queryCore.isServer) {
|
|
34
|
-
client.mount();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let persisterUnmount = () => {// noop
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if (options.clientPersister) {
|
|
41
|
-
client.isRestoring.value = true;
|
|
42
|
-
const [unmount, promise] = options.clientPersister(client);
|
|
43
|
-
persisterUnmount = unmount;
|
|
44
|
-
promise.then(() => {
|
|
45
|
-
client.isRestoring.value = false;
|
|
46
|
-
options.clientPersisterOnSuccess == null ? void 0 : options.clientPersisterOnSuccess(client);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (process.env.NODE_ENV !== 'production' && options.contextSharing) {
|
|
51
|
-
client.getLogger().error("The contextSharing option has been deprecated and will be removed in the next major version");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const cleanup = () => {
|
|
55
|
-
client.unmount();
|
|
56
|
-
persisterUnmount();
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (app.onUnmount) {
|
|
60
|
-
app.onUnmount(cleanup);
|
|
61
|
-
} else {
|
|
62
|
-
const originalUnmount = app.unmount;
|
|
63
|
-
|
|
64
|
-
app.unmount = function vueQueryUnmount() {
|
|
65
|
-
cleanup();
|
|
66
|
-
originalUnmount();
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/* istanbul ignore next */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (vueDemi.isVue2) {
|
|
73
|
-
app.mixin({
|
|
74
|
-
beforeCreate() {
|
|
75
|
-
// HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30
|
|
76
|
-
if (!this._provided) {
|
|
77
|
-
const provideCache = {};
|
|
78
|
-
Object.defineProperty(this, '_provided', {
|
|
79
|
-
get: () => provideCache,
|
|
80
|
-
set: v => Object.assign(provideCache, v)
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
this._provided[clientKey] = client;
|
|
85
|
-
|
|
86
|
-
if (process.env.NODE_ENV === 'development') {
|
|
87
|
-
if (this === this.$root) {
|
|
88
|
-
devtools.setupDevtools(this, client);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
app.provide(clientKey, client);
|
|
96
|
-
|
|
97
|
-
if (process.env.NODE_ENV === 'development') {
|
|
98
|
-
devtools.setupDevtools(app, client);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
exports.VueQueryPlugin = VueQueryPlugin;
|
|
105
|
-
//# sourceMappingURL=vueQueryPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.js","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from '@tanstack/query-core'\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 clientPersisterOnSuccess?: (client: QueryClient) => void\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 options.clientPersisterOnSuccess?.(client)\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","clientPersisterOnSuccess","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":";;;;;;;;;;AAkCO,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;UAC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AACD,OAAA;AACF,KAAA;AACF,GAAA;AAhG2B;;;;"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { isVue2 } from 'vue-demi';
|
|
2
|
-
import { isServer } from '@tanstack/query-core';
|
|
3
|
-
import { QueryClient } from './queryClient.mjs';
|
|
4
|
-
import { getClientKey } from './utils.mjs';
|
|
5
|
-
import { setupDevtools } from './devtools/devtools.mjs';
|
|
6
|
-
|
|
7
|
-
const VueQueryPlugin = {
|
|
8
|
-
install: (app, options = {}) => {
|
|
9
|
-
const clientKey = getClientKey(options.queryClientKey);
|
|
10
|
-
let client;
|
|
11
|
-
|
|
12
|
-
if ('queryClient' in options && options.queryClient) {
|
|
13
|
-
client = options.queryClient;
|
|
14
|
-
} else {
|
|
15
|
-
if (options.contextSharing && typeof window !== 'undefined') {
|
|
16
|
-
if (!window.__VUE_QUERY_CONTEXT__) {
|
|
17
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
18
|
-
client = new QueryClient(clientConfig);
|
|
19
|
-
window.__VUE_QUERY_CONTEXT__ = client;
|
|
20
|
-
} else {
|
|
21
|
-
client = window.__VUE_QUERY_CONTEXT__;
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
const clientConfig = 'queryClientConfig' in options ? options.queryClientConfig : undefined;
|
|
25
|
-
client = new QueryClient(clientConfig);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!isServer) {
|
|
30
|
-
client.mount();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let persisterUnmount = () => {// noop
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (options.clientPersister) {
|
|
37
|
-
client.isRestoring.value = true;
|
|
38
|
-
const [unmount, promise] = options.clientPersister(client);
|
|
39
|
-
persisterUnmount = unmount;
|
|
40
|
-
promise.then(() => {
|
|
41
|
-
client.isRestoring.value = false;
|
|
42
|
-
options.clientPersisterOnSuccess == null ? void 0 : options.clientPersisterOnSuccess(client);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
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
|
-
const cleanup = () => {
|
|
51
|
-
client.unmount();
|
|
52
|
-
persisterUnmount();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
if (app.onUnmount) {
|
|
56
|
-
app.onUnmount(cleanup);
|
|
57
|
-
} else {
|
|
58
|
-
const originalUnmount = app.unmount;
|
|
59
|
-
|
|
60
|
-
app.unmount = function vueQueryUnmount() {
|
|
61
|
-
cleanup();
|
|
62
|
-
originalUnmount();
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/* istanbul ignore next */
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (isVue2) {
|
|
69
|
-
app.mixin({
|
|
70
|
-
beforeCreate() {
|
|
71
|
-
// HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30
|
|
72
|
-
if (!this._provided) {
|
|
73
|
-
const provideCache = {};
|
|
74
|
-
Object.defineProperty(this, '_provided', {
|
|
75
|
-
get: () => provideCache,
|
|
76
|
-
set: v => Object.assign(provideCache, v)
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this._provided[clientKey] = client;
|
|
81
|
-
|
|
82
|
-
if (process.env.NODE_ENV === 'development') {
|
|
83
|
-
if (this === this.$root) {
|
|
84
|
-
setupDevtools(this, client);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
app.provide(clientKey, client);
|
|
92
|
-
|
|
93
|
-
if (process.env.NODE_ENV === 'development') {
|
|
94
|
-
setupDevtools(app, client);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export { VueQueryPlugin };
|
|
101
|
-
//# sourceMappingURL=vueQueryPlugin.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.mjs","sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { isServer } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from '@tanstack/query-core'\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 clientPersisterOnSuccess?: (client: QueryClient) => void\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 options.clientPersisterOnSuccess?.(client)\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","clientPersisterOnSuccess","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":";;;;;;AAkCO,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,IA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