react-query-kit 1.5.1 → 1.5.2
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 +17 -31
- package/build/lib/createBaseQuery.esm.js +12 -11
- package/build/lib/createBaseQuery.esm.js.map +1 -1
- package/build/lib/createBaseQuery.js +11 -10
- package/build/lib/createBaseQuery.js.map +1 -1
- package/build/lib/createBaseQuery.mjs +12 -11
- package/build/lib/createBaseQuery.mjs.map +1 -1
- package/build/lib/createInfiniteQuery.d.ts +1 -1
- package/build/lib/createInfiniteQuery.esm.js +2 -2
- package/build/lib/createInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createInfiniteQuery.js +2 -2
- package/build/lib/createInfiniteQuery.js.map +1 -1
- package/build/lib/createInfiniteQuery.mjs +2 -2
- package/build/lib/createInfiniteQuery.mjs.map +1 -1
- package/build/lib/createMutation.d.ts +1 -1
- package/build/lib/createMutation.esm.js +4 -4
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js +3 -3
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs +4 -4
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.d.ts +1 -1
- package/build/lib/createQuery.esm.js +2 -2
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js +2 -2
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs +2 -2
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.d.ts +1 -1
- package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js +2 -2
- package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs +2 -2
- package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
- package/build/lib/createSuspenseQuery.d.ts +1 -1
- package/build/lib/createSuspenseQuery.esm.js +2 -2
- package/build/lib/createSuspenseQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseQuery.js +2 -2
- package/build/lib/createSuspenseQuery.js.map +1 -1
- package/build/lib/createSuspenseQuery.mjs +2 -2
- package/build/lib/createSuspenseQuery.mjs.map +1 -1
- package/build/lib/index.d.ts +1 -2
- package/build/lib/index.esm.js +0 -1
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +0 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +0 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/types.d.ts +18 -16
- package/build/lib/utils.d.ts +4 -4
- package/build/lib/utils.esm.js +20 -19
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +20 -19
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +20 -19
- package/build/lib/utils.mjs.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +91 -129
- package/build/umd/index.development.js +41 -54
- 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/src/createBaseQuery.ts +32 -33
- package/src/createInfiniteQuery.ts +2 -2
- package/src/createMutation.ts +4 -4
- package/src/createQuery.tsx +2 -2
- package/src/createSuspenseInfiniteQuery.ts +2 -2
- package/src/createSuspenseQuery.ts +2 -2
- package/src/index.ts +1 -4
- package/src/types.ts +117 -111
- package/src/utils.ts +22 -14
- package/build/lib/createImmutableQuery.d.ts +0 -6
- package/build/lib/createImmutableQuery.esm.js +0 -19
- package/build/lib/createImmutableQuery.esm.js.map +0 -1
- package/build/lib/createImmutableQuery.js +0 -23
- package/build/lib/createImmutableQuery.js.map +0 -1
- package/build/lib/createImmutableQuery.mjs +0 -19
- package/build/lib/createImmutableQuery.mjs.map +0 -1
- package/src/createImmutableQuery.tsx +0 -54
package/build/lib/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["import { QueryClient, useQueryClient } from '@tanstack/react-query'\n\nimport { CompatibleWithV4, Middleware } from './types'\n\nexport const useCompatibeQueryClient = (\n options?: any,\n queryClient?: CompatibleWithV4<QueryClient, void>\n)
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["import { QueryClient, useQueryClient } from '@tanstack/react-query'\n\nimport { CompatibleWithV4, Middleware } from './types'\n\nexport const useCompatibeQueryClient = (\n options?: any,\n queryClient?: CompatibleWithV4<QueryClient, void>\n) => {\n return useQueryClient(\n // compatible with ReactQuery v4\n // @ts-ignore\n options?.context ? { context: options.context } : queryClient\n )\n}\n\nexport const withMiddleware = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n return function useMiddleware(\n options?: { client?: QueryClient; use?: Middleware[] },\n queryClient?: CompatibleWithV4<QueryClient, void>\n ) {\n const client = useCompatibeQueryClient(options, queryClient)\n const [middleware, opts] = [\n client.getDefaultOptions()[type],\n defaultOptions,\n options,\n ].reduce(\n (acc, item = {}) => {\n const [middleware, opts] = acc\n const { use = [], ...rest } = item\n return [[...middleware, ...use], { ...opts, ...rest }]\n },\n [[], {}]\n )\n\n let next = hook\n for (let i = middleware.length; i--; ) {\n next = middleware[i](next)\n }\n\n return next(opts, queryClient)\n }\n}\n\nexport const getQueryKey = <TVariables>(\n primaryKey: string,\n variables?: TVariables\n) => {\n return variables === undefined ? [primaryKey] : [primaryKey, variables]\n}\n"],"names":["useCompatibeQueryClient","options","queryClient","useQueryClient","context","withMiddleware","hook","defaultOptions","type","useMiddleware","client","middleware","opts","getDefaultOptions","reduce","acc","item","use","rest","next","i","length","getQueryKey","primaryKey","variables","undefined"],"mappings":";;MAIaA,uBAAuB,GAAG,CACrCC,OADqC,EAErCC,WAFqC,KAGlC;AACH,EAAA,OAAOC,cAAc;AAEnB;AACAF,EAAAA,OAAO,IAAP,IAAA,IAAAA,OAAO,CAAEG,OAAT,GAAmB;IAAEA,OAAO,EAAEH,OAAO,CAACG,OAAAA;GAAtC,GAAkDF,WAH/B,CAArB,CAAA;AAKD,EATM;AAWA,MAAMG,cAAc,GAAG,CAC5BC,IAD4B,EAE5BC,cAF4B,EAG5BC,IAH4B,KAIzB;AACH,EAAA,OAAO,SAASC,aAAT,CACLR,OADK,EAELC,WAFK,EAGL;AACA,IAAA,MAAMQ,MAAM,GAAGV,uBAAuB,CAACC,OAAD,EAAUC,WAAV,CAAtC,CAAA;IACA,MAAM,CAACS,UAAD,EAAaC,IAAb,CAAA,GAAqB,CACzBF,MAAM,CAACG,iBAAP,EAAA,CAA2BL,IAA3B,CADyB,EAEzBD,cAFyB,EAGzBN,OAHyB,CAAA,CAIzBa,MAJyB,CAKzB,CAACC,GAAD,EAAMC,IAAI,GAAG,EAAb,KAAoB;AAClB,MAAA,MAAM,CAACL,UAAD,EAAaC,IAAb,IAAqBG,GAA3B,CAAA;MACA,MAAM;AAAEE,QAAAA,GAAG,GAAG,EAAR;QAAY,GAAGC,IAAAA;AAAf,OAAA,GAAwBF,IAA9B,CAAA;MACA,OAAO,CAAC,CAAC,GAAGL,UAAJ,EAAgB,GAAGM,GAAnB,CAAD,EAA0B,EAAE,GAAGL,IAAL;QAAW,GAAGM,IAAAA;AAAd,OAA1B,CAAP,CAAA;AACD,KATwB,EAUzB,CAAC,EAAD,EAAK,EAAL,CAVyB,CAA3B,CAAA;IAaA,IAAIC,IAAI,GAAGb,IAAX,CAAA;;IACA,KAAK,IAAIc,CAAC,GAAGT,UAAU,CAACU,MAAxB,EAAgCD,CAAC,EAAjC,GAAuC;AACrCD,MAAAA,IAAI,GAAGR,UAAU,CAACS,CAAD,CAAV,CAAcD,IAAd,CAAP,CAAA;AACD,KAAA;;AAED,IAAA,OAAOA,IAAI,CAACP,IAAD,EAAOV,WAAP,CAAX,CAAA;GAvBF,CAAA;AAyBD,EA9BM;MAgCMoB,WAAW,GAAG,CACzBC,UADyB,EAEzBC,SAFyB,KAGtB;AACH,EAAA,OAAOA,SAAS,KAAKC,SAAd,GAA0B,CAACF,UAAD,CAA1B,GAAyC,CAACA,UAAD,EAAaC,SAAb,CAAhD,CAAA;AACD;;;;"}
|
package/build/stats-html.html
CHANGED
|
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
|
|
|
4014
4014
|
</script>
|
|
4015
4015
|
<script>
|
|
4016
4016
|
/*<!--*/
|
|
4017
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"src","children":[{"uid":"
|
|
4017
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"src","children":[{"uid":"24d3-1","name":"utils.ts"},{"uid":"24d3-3","name":"createBaseQuery.ts"},{"uid":"24d3-5","name":"createQuery.tsx"},{"uid":"24d3-7","name":"createSuspenseQuery.ts"},{"uid":"24d3-9","name":"createInfiniteQuery.ts"},{"uid":"24d3-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"24d3-13","name":"createMutation.ts"},{"uid":"24d3-15","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"24d3-1":{"renderedLength":1070,"gzipLength":444,"brotliLength":0,"mainUid":"24d3-0"},"24d3-3":{"renderedLength":1470,"gzipLength":495,"brotliLength":0,"mainUid":"24d3-2"},"24d3-5":{"renderedLength":97,"gzipLength":90,"brotliLength":0,"mainUid":"24d3-4"},"24d3-7":{"renderedLength":271,"gzipLength":177,"brotliLength":0,"mainUid":"24d3-6"},"24d3-9":{"renderedLength":113,"gzipLength":99,"brotliLength":0,"mainUid":"24d3-8"},"24d3-11":{"renderedLength":287,"gzipLength":186,"brotliLength":0,"mainUid":"24d3-10"},"24d3-13":{"renderedLength":265,"gzipLength":173,"brotliLength":0,"mainUid":"24d3-12"},"24d3-15":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"24d3-14"}},"nodeMetas":{"24d3-0":{"id":"/src/utils.ts","moduleParts":{"index.production.js":"24d3-1"},"imported":[{"uid":"24d3-16"}],"importedBy":[{"uid":"24d3-14"},{"uid":"24d3-12"},{"uid":"24d3-2"}]},"24d3-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"index.production.js":"24d3-3"},"imported":[{"uid":"24d3-0"}],"importedBy":[{"uid":"24d3-4"},{"uid":"24d3-6"},{"uid":"24d3-8"},{"uid":"24d3-10"}]},"24d3-4":{"id":"/src/createQuery.tsx","moduleParts":{"index.production.js":"24d3-5"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"index.production.js":"24d3-7"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"index.production.js":"24d3-9"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"index.production.js":"24d3-11"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-12":{"id":"/src/createMutation.ts","moduleParts":{"index.production.js":"24d3-13"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-0"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-14":{"id":"/src/index.ts","moduleParts":{"index.production.js":"24d3-15"},"imported":[{"uid":"24d3-4"},{"uid":"24d3-6"},{"uid":"24d3-8"},{"uid":"24d3-10"},{"uid":"24d3-12"},{"uid":"24d3-0"}],"importedBy":[],"isEntry":true},"24d3-16":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"24d3-4"},{"uid":"24d3-6"},{"uid":"24d3-8"},{"uid":"24d3-10"},{"uid":"24d3-12"},{"uid":"24d3-0"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
4018
4018
|
|
|
4019
4019
|
const run = () => {
|
|
4020
4020
|
const width = window.innerWidth;
|
package/build/stats.json
CHANGED
|
@@ -10,39 +10,35 @@
|
|
|
10
10
|
"name": "src",
|
|
11
11
|
"children": [
|
|
12
12
|
{
|
|
13
|
-
"uid": "
|
|
13
|
+
"uid": "24d3-18",
|
|
14
14
|
"name": "utils.ts"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
"uid": "
|
|
17
|
+
"uid": "24d3-20",
|
|
18
18
|
"name": "createBaseQuery.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"uid": "
|
|
21
|
+
"uid": "24d3-22",
|
|
22
22
|
"name": "createQuery.tsx"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"uid": "
|
|
26
|
-
"name": "createImmutableQuery.tsx"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"uid": "d114-28",
|
|
25
|
+
"uid": "24d3-24",
|
|
30
26
|
"name": "createSuspenseQuery.ts"
|
|
31
27
|
},
|
|
32
28
|
{
|
|
33
|
-
"uid": "
|
|
29
|
+
"uid": "24d3-26",
|
|
34
30
|
"name": "createInfiniteQuery.ts"
|
|
35
31
|
},
|
|
36
32
|
{
|
|
37
|
-
"uid": "
|
|
33
|
+
"uid": "24d3-28",
|
|
38
34
|
"name": "createSuspenseInfiniteQuery.ts"
|
|
39
35
|
},
|
|
40
36
|
{
|
|
41
|
-
"uid": "
|
|
37
|
+
"uid": "24d3-30",
|
|
42
38
|
"name": "createMutation.ts"
|
|
43
39
|
},
|
|
44
40
|
{
|
|
45
|
-
"uid": "
|
|
41
|
+
"uid": "24d3-32",
|
|
46
42
|
"name": "index.ts"
|
|
47
43
|
}
|
|
48
44
|
]
|
|
@@ -53,282 +49,248 @@
|
|
|
53
49
|
"isRoot": true
|
|
54
50
|
},
|
|
55
51
|
"nodeParts": {
|
|
56
|
-
"
|
|
57
|
-
"renderedLength":
|
|
58
|
-
"gzipLength":
|
|
59
|
-
"brotliLength": 0,
|
|
60
|
-
"mainUid": "d114-19"
|
|
61
|
-
},
|
|
62
|
-
"d114-22": {
|
|
63
|
-
"renderedLength": 1585,
|
|
64
|
-
"gzipLength": 512,
|
|
52
|
+
"24d3-18": {
|
|
53
|
+
"renderedLength": 1070,
|
|
54
|
+
"gzipLength": 444,
|
|
65
55
|
"brotliLength": 0,
|
|
66
|
-
"mainUid": "
|
|
56
|
+
"mainUid": "24d3-17"
|
|
67
57
|
},
|
|
68
|
-
"
|
|
69
|
-
"renderedLength":
|
|
70
|
-
"gzipLength":
|
|
58
|
+
"24d3-20": {
|
|
59
|
+
"renderedLength": 1470,
|
|
60
|
+
"gzipLength": 495,
|
|
71
61
|
"brotliLength": 0,
|
|
72
|
-
"mainUid": "
|
|
62
|
+
"mainUid": "24d3-19"
|
|
73
63
|
},
|
|
74
|
-
"
|
|
75
|
-
"renderedLength":
|
|
76
|
-
"gzipLength":
|
|
64
|
+
"24d3-22": {
|
|
65
|
+
"renderedLength": 97,
|
|
66
|
+
"gzipLength": 90,
|
|
77
67
|
"brotliLength": 0,
|
|
78
|
-
"mainUid": "
|
|
68
|
+
"mainUid": "24d3-21"
|
|
79
69
|
},
|
|
80
|
-
"
|
|
81
|
-
"renderedLength":
|
|
82
|
-
"gzipLength":
|
|
70
|
+
"24d3-24": {
|
|
71
|
+
"renderedLength": 271,
|
|
72
|
+
"gzipLength": 177,
|
|
83
73
|
"brotliLength": 0,
|
|
84
|
-
"mainUid": "
|
|
74
|
+
"mainUid": "24d3-23"
|
|
85
75
|
},
|
|
86
|
-
"
|
|
87
|
-
"renderedLength":
|
|
88
|
-
"gzipLength":
|
|
76
|
+
"24d3-26": {
|
|
77
|
+
"renderedLength": 113,
|
|
78
|
+
"gzipLength": 99,
|
|
89
79
|
"brotliLength": 0,
|
|
90
|
-
"mainUid": "
|
|
80
|
+
"mainUid": "24d3-25"
|
|
91
81
|
},
|
|
92
|
-
"
|
|
93
|
-
"renderedLength":
|
|
94
|
-
"gzipLength":
|
|
82
|
+
"24d3-28": {
|
|
83
|
+
"renderedLength": 287,
|
|
84
|
+
"gzipLength": 186,
|
|
95
85
|
"brotliLength": 0,
|
|
96
|
-
"mainUid": "
|
|
86
|
+
"mainUid": "24d3-27"
|
|
97
87
|
},
|
|
98
|
-
"
|
|
99
|
-
"renderedLength":
|
|
100
|
-
"gzipLength":
|
|
88
|
+
"24d3-30": {
|
|
89
|
+
"renderedLength": 265,
|
|
90
|
+
"gzipLength": 173,
|
|
101
91
|
"brotliLength": 0,
|
|
102
|
-
"mainUid": "
|
|
92
|
+
"mainUid": "24d3-29"
|
|
103
93
|
},
|
|
104
|
-
"
|
|
94
|
+
"24d3-32": {
|
|
105
95
|
"renderedLength": 0,
|
|
106
96
|
"gzipLength": 0,
|
|
107
97
|
"brotliLength": 0,
|
|
108
|
-
"mainUid": "
|
|
98
|
+
"mainUid": "24d3-31"
|
|
109
99
|
}
|
|
110
100
|
},
|
|
111
101
|
"nodeMetas": {
|
|
112
|
-
"
|
|
102
|
+
"24d3-17": {
|
|
113
103
|
"id": "/src/utils.ts",
|
|
114
104
|
"moduleParts": {
|
|
115
|
-
"index.production.js": "
|
|
105
|
+
"index.production.js": "24d3-18"
|
|
116
106
|
},
|
|
117
107
|
"imported": [
|
|
118
108
|
{
|
|
119
|
-
"uid": "
|
|
109
|
+
"uid": "24d3-33"
|
|
120
110
|
}
|
|
121
111
|
],
|
|
122
112
|
"importedBy": [
|
|
123
113
|
{
|
|
124
|
-
"uid": "
|
|
114
|
+
"uid": "24d3-31"
|
|
125
115
|
},
|
|
126
116
|
{
|
|
127
|
-
"uid": "
|
|
117
|
+
"uid": "24d3-29"
|
|
128
118
|
},
|
|
129
119
|
{
|
|
130
|
-
"uid": "
|
|
120
|
+
"uid": "24d3-19"
|
|
131
121
|
}
|
|
132
122
|
]
|
|
133
123
|
},
|
|
134
|
-
"
|
|
124
|
+
"24d3-19": {
|
|
135
125
|
"id": "/src/createBaseQuery.ts",
|
|
136
126
|
"moduleParts": {
|
|
137
|
-
"index.production.js": "
|
|
127
|
+
"index.production.js": "24d3-20"
|
|
138
128
|
},
|
|
139
129
|
"imported": [
|
|
140
130
|
{
|
|
141
|
-
"uid": "
|
|
131
|
+
"uid": "24d3-17"
|
|
142
132
|
}
|
|
143
133
|
],
|
|
144
134
|
"importedBy": [
|
|
145
135
|
{
|
|
146
|
-
"uid": "
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"uid": "d114-25"
|
|
136
|
+
"uid": "24d3-21"
|
|
150
137
|
},
|
|
151
138
|
{
|
|
152
|
-
"uid": "
|
|
139
|
+
"uid": "24d3-23"
|
|
153
140
|
},
|
|
154
141
|
{
|
|
155
|
-
"uid": "
|
|
142
|
+
"uid": "24d3-25"
|
|
156
143
|
},
|
|
157
144
|
{
|
|
158
|
-
"uid": "
|
|
145
|
+
"uid": "24d3-27"
|
|
159
146
|
}
|
|
160
147
|
]
|
|
161
148
|
},
|
|
162
|
-
"
|
|
149
|
+
"24d3-21": {
|
|
163
150
|
"id": "/src/createQuery.tsx",
|
|
164
151
|
"moduleParts": {
|
|
165
|
-
"index.production.js": "
|
|
152
|
+
"index.production.js": "24d3-22"
|
|
166
153
|
},
|
|
167
154
|
"imported": [
|
|
168
155
|
{
|
|
169
|
-
"uid": "
|
|
156
|
+
"uid": "24d3-33"
|
|
170
157
|
},
|
|
171
158
|
{
|
|
172
|
-
"uid": "
|
|
159
|
+
"uid": "24d3-19"
|
|
173
160
|
}
|
|
174
161
|
],
|
|
175
162
|
"importedBy": [
|
|
176
163
|
{
|
|
177
|
-
"uid": "
|
|
164
|
+
"uid": "24d3-31"
|
|
178
165
|
}
|
|
179
166
|
]
|
|
180
167
|
},
|
|
181
|
-
"
|
|
182
|
-
"id": "/src/createImmutableQuery.tsx",
|
|
183
|
-
"moduleParts": {
|
|
184
|
-
"index.production.js": "d114-26"
|
|
185
|
-
},
|
|
186
|
-
"imported": [
|
|
187
|
-
{
|
|
188
|
-
"uid": "d114-37"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
"uid": "d114-21"
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
"importedBy": [
|
|
195
|
-
{
|
|
196
|
-
"uid": "d114-35"
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
},
|
|
200
|
-
"d114-27": {
|
|
168
|
+
"24d3-23": {
|
|
201
169
|
"id": "/src/createSuspenseQuery.ts",
|
|
202
170
|
"moduleParts": {
|
|
203
|
-
"index.production.js": "
|
|
171
|
+
"index.production.js": "24d3-24"
|
|
204
172
|
},
|
|
205
173
|
"imported": [
|
|
206
174
|
{
|
|
207
|
-
"uid": "
|
|
175
|
+
"uid": "24d3-33"
|
|
208
176
|
},
|
|
209
177
|
{
|
|
210
|
-
"uid": "
|
|
178
|
+
"uid": "24d3-19"
|
|
211
179
|
}
|
|
212
180
|
],
|
|
213
181
|
"importedBy": [
|
|
214
182
|
{
|
|
215
|
-
"uid": "
|
|
183
|
+
"uid": "24d3-31"
|
|
216
184
|
}
|
|
217
185
|
]
|
|
218
186
|
},
|
|
219
|
-
"
|
|
187
|
+
"24d3-25": {
|
|
220
188
|
"id": "/src/createInfiniteQuery.ts",
|
|
221
189
|
"moduleParts": {
|
|
222
|
-
"index.production.js": "
|
|
190
|
+
"index.production.js": "24d3-26"
|
|
223
191
|
},
|
|
224
192
|
"imported": [
|
|
225
193
|
{
|
|
226
|
-
"uid": "
|
|
194
|
+
"uid": "24d3-33"
|
|
227
195
|
},
|
|
228
196
|
{
|
|
229
|
-
"uid": "
|
|
197
|
+
"uid": "24d3-19"
|
|
230
198
|
}
|
|
231
199
|
],
|
|
232
200
|
"importedBy": [
|
|
233
201
|
{
|
|
234
|
-
"uid": "
|
|
202
|
+
"uid": "24d3-31"
|
|
235
203
|
}
|
|
236
204
|
]
|
|
237
205
|
},
|
|
238
|
-
"
|
|
206
|
+
"24d3-27": {
|
|
239
207
|
"id": "/src/createSuspenseInfiniteQuery.ts",
|
|
240
208
|
"moduleParts": {
|
|
241
|
-
"index.production.js": "
|
|
209
|
+
"index.production.js": "24d3-28"
|
|
242
210
|
},
|
|
243
211
|
"imported": [
|
|
244
212
|
{
|
|
245
|
-
"uid": "
|
|
213
|
+
"uid": "24d3-33"
|
|
246
214
|
},
|
|
247
215
|
{
|
|
248
|
-
"uid": "
|
|
216
|
+
"uid": "24d3-19"
|
|
249
217
|
}
|
|
250
218
|
],
|
|
251
219
|
"importedBy": [
|
|
252
220
|
{
|
|
253
|
-
"uid": "
|
|
221
|
+
"uid": "24d3-31"
|
|
254
222
|
}
|
|
255
223
|
]
|
|
256
224
|
},
|
|
257
|
-
"
|
|
225
|
+
"24d3-29": {
|
|
258
226
|
"id": "/src/createMutation.ts",
|
|
259
227
|
"moduleParts": {
|
|
260
|
-
"index.production.js": "
|
|
228
|
+
"index.production.js": "24d3-30"
|
|
261
229
|
},
|
|
262
230
|
"imported": [
|
|
263
231
|
{
|
|
264
|
-
"uid": "
|
|
232
|
+
"uid": "24d3-33"
|
|
265
233
|
},
|
|
266
234
|
{
|
|
267
|
-
"uid": "
|
|
235
|
+
"uid": "24d3-17"
|
|
268
236
|
}
|
|
269
237
|
],
|
|
270
238
|
"importedBy": [
|
|
271
239
|
{
|
|
272
|
-
"uid": "
|
|
240
|
+
"uid": "24d3-31"
|
|
273
241
|
}
|
|
274
242
|
]
|
|
275
243
|
},
|
|
276
|
-
"
|
|
244
|
+
"24d3-31": {
|
|
277
245
|
"id": "/src/index.ts",
|
|
278
246
|
"moduleParts": {
|
|
279
|
-
"index.production.js": "
|
|
247
|
+
"index.production.js": "24d3-32"
|
|
280
248
|
},
|
|
281
249
|
"imported": [
|
|
282
250
|
{
|
|
283
|
-
"uid": "
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
"uid": "d114-25"
|
|
251
|
+
"uid": "24d3-21"
|
|
287
252
|
},
|
|
288
253
|
{
|
|
289
|
-
"uid": "
|
|
254
|
+
"uid": "24d3-23"
|
|
290
255
|
},
|
|
291
256
|
{
|
|
292
|
-
"uid": "
|
|
257
|
+
"uid": "24d3-25"
|
|
293
258
|
},
|
|
294
259
|
{
|
|
295
|
-
"uid": "
|
|
260
|
+
"uid": "24d3-27"
|
|
296
261
|
},
|
|
297
262
|
{
|
|
298
|
-
"uid": "
|
|
263
|
+
"uid": "24d3-29"
|
|
299
264
|
},
|
|
300
265
|
{
|
|
301
|
-
"uid": "
|
|
266
|
+
"uid": "24d3-17"
|
|
302
267
|
}
|
|
303
268
|
],
|
|
304
269
|
"importedBy": [],
|
|
305
270
|
"isEntry": true
|
|
306
271
|
},
|
|
307
|
-
"
|
|
272
|
+
"24d3-33": {
|
|
308
273
|
"id": "@tanstack/react-query",
|
|
309
274
|
"moduleParts": {},
|
|
310
275
|
"imported": [],
|
|
311
276
|
"importedBy": [
|
|
312
277
|
{
|
|
313
|
-
"uid": "
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
"uid": "d114-25"
|
|
278
|
+
"uid": "24d3-21"
|
|
317
279
|
},
|
|
318
280
|
{
|
|
319
|
-
"uid": "
|
|
281
|
+
"uid": "24d3-23"
|
|
320
282
|
},
|
|
321
283
|
{
|
|
322
|
-
"uid": "
|
|
284
|
+
"uid": "24d3-25"
|
|
323
285
|
},
|
|
324
286
|
{
|
|
325
|
-
"uid": "
|
|
287
|
+
"uid": "24d3-27"
|
|
326
288
|
},
|
|
327
289
|
{
|
|
328
|
-
"uid": "
|
|
290
|
+
"uid": "24d3-29"
|
|
329
291
|
},
|
|
330
292
|
{
|
|
331
|
-
"uid": "
|
|
293
|
+
"uid": "24d3-17"
|
|
332
294
|
}
|
|
333
295
|
],
|
|
334
296
|
"isExternal": true
|
|
@@ -4,32 +4,33 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryKit = {}, global.ReactQuery));
|
|
5
5
|
})(this, (function (exports, reactQuery) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const useCompatibeQueryClient = (options, queryClient) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = defaultOptions;
|
|
7
|
+
const useCompatibeQueryClient = (options, queryClient) => {
|
|
8
|
+
return reactQuery.useQueryClient( // compatible with ReactQuery v4
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
options != null && options.context ? {
|
|
11
|
+
context: options.context
|
|
12
|
+
} : queryClient);
|
|
13
|
+
};
|
|
14
|
+
const withMiddleware = (hook, defaultOptions, type) => {
|
|
16
15
|
return function useMiddleware(options, queryClient) {
|
|
17
16
|
const client = useCompatibeQueryClient(options, queryClient);
|
|
17
|
+
const [middleware, opts] = [client.getDefaultOptions()[type], defaultOptions, options].reduce((acc, item = {}) => {
|
|
18
|
+
const [middleware, opts] = acc;
|
|
19
|
+
const {
|
|
20
|
+
use = [],
|
|
21
|
+
...rest
|
|
22
|
+
} = item;
|
|
23
|
+
return [[...middleware, ...use], { ...opts,
|
|
24
|
+
...rest
|
|
25
|
+
}];
|
|
26
|
+
}, [[], {}]);
|
|
18
27
|
let next = hook;
|
|
19
|
-
const {
|
|
20
|
-
use: configUse = [],
|
|
21
|
-
...configOptions
|
|
22
|
-
} = client.getDefaultOptions()[type] || {};
|
|
23
|
-
const middleware = configUse.concat(use);
|
|
24
28
|
|
|
25
29
|
for (let i = middleware.length; i--;) {
|
|
26
30
|
next = middleware[i](next);
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
return next(
|
|
30
|
-
...restOptions,
|
|
31
|
-
...options
|
|
32
|
-
}, queryClient);
|
|
33
|
+
return next(opts, queryClient);
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
36
|
const getQueryKey = (primaryKey, variables) => {
|
|
@@ -38,7 +39,9 @@
|
|
|
38
39
|
|
|
39
40
|
function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
40
41
|
const {
|
|
41
|
-
primaryKey
|
|
42
|
+
primaryKey,
|
|
43
|
+
queryFn,
|
|
44
|
+
queryKeyHashFn
|
|
42
45
|
} = defaultOptions;
|
|
43
46
|
|
|
44
47
|
{
|
|
@@ -55,15 +58,15 @@
|
|
|
55
58
|
const getFetchOptions = variables => {
|
|
56
59
|
return {
|
|
57
60
|
queryKey: getKey(variables),
|
|
58
|
-
queryFn
|
|
59
|
-
queryKeyHashFn
|
|
61
|
+
queryFn,
|
|
62
|
+
queryKeyHashFn,
|
|
60
63
|
getPreviousPageParam: defaultOptions.getPreviousPageParam,
|
|
61
64
|
getNextPageParam: defaultOptions.getNextPageParam,
|
|
62
65
|
initialPageParam: defaultOptions.initialPageParam
|
|
63
66
|
};
|
|
64
67
|
};
|
|
65
68
|
|
|
66
|
-
const
|
|
69
|
+
const useBaseHook = (options, queryClient) => {
|
|
67
70
|
const client = useCompatibeQueryClient(options, queryClient);
|
|
68
71
|
const {
|
|
69
72
|
enabled,
|
|
@@ -73,45 +76,30 @@
|
|
|
73
76
|
...overrideOptions
|
|
74
77
|
};
|
|
75
78
|
const queryKey = getKey(variables);
|
|
76
|
-
|
|
79
|
+
return Object.assign(useRQHook({ ...mergedOptions,
|
|
77
80
|
enabled: typeof enabled === 'function' ? enabled(client.getQueryData(queryKey), variables) : enabled,
|
|
78
81
|
queryKey
|
|
79
|
-
}, client)
|
|
80
|
-
return Object.assign(result, {
|
|
82
|
+
}, client), {
|
|
81
83
|
queryKey: queryKey,
|
|
82
84
|
variables,
|
|
83
85
|
setData: (updater, setDataOptions) => client.setQueryData(queryKey, updater, setDataOptions)
|
|
84
86
|
});
|
|
85
87
|
};
|
|
86
88
|
|
|
87
|
-
return Object.assign(
|
|
89
|
+
return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {
|
|
88
90
|
getPrimaryKey,
|
|
89
91
|
getKey,
|
|
90
|
-
queryFn
|
|
91
|
-
queryKeyHashFn
|
|
92
|
+
queryFn,
|
|
93
|
+
queryKeyHashFn,
|
|
92
94
|
getFetchOptions
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
const createQuery = options => {
|
|
97
99
|
return createBaseQuery(options, reactQuery.useQuery);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function createImmutableQuery(options) {
|
|
101
|
-
return createBaseQuery(options, reactQuery.useQuery, {
|
|
102
|
-
refetchInterval: false,
|
|
103
|
-
refetchOnMount: false,
|
|
104
|
-
refetchOnReconnect: false,
|
|
105
|
-
refetchOnWindowFocus: false,
|
|
106
|
-
staleTime: Infinity,
|
|
107
|
-
gcTime: Infinity,
|
|
108
|
-
// compatible with ReactQuery v4
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
cacheTime: Infinity
|
|
111
|
-
});
|
|
112
|
-
}
|
|
100
|
+
};
|
|
113
101
|
|
|
114
|
-
|
|
102
|
+
const createSuspenseQuery = options => {
|
|
115
103
|
return createBaseQuery(options, reactQuery.useQuery, {
|
|
116
104
|
enabled: true,
|
|
117
105
|
suspense: true,
|
|
@@ -120,13 +108,13 @@
|
|
|
120
108
|
// @ts-ignore
|
|
121
109
|
useErrorBoundary: true
|
|
122
110
|
});
|
|
123
|
-
}
|
|
111
|
+
};
|
|
124
112
|
|
|
125
|
-
|
|
113
|
+
const createInfiniteQuery = options => {
|
|
126
114
|
return createBaseQuery(options, reactQuery.useInfiniteQuery);
|
|
127
|
-
}
|
|
115
|
+
};
|
|
128
116
|
|
|
129
|
-
|
|
117
|
+
const createSuspenseInfiniteQuery = options => {
|
|
130
118
|
return createBaseQuery(options, reactQuery.useInfiniteQuery, {
|
|
131
119
|
enabled: true,
|
|
132
120
|
suspense: true,
|
|
@@ -135,18 +123,17 @@
|
|
|
135
123
|
// @ts-ignore
|
|
136
124
|
useErrorBoundary: true
|
|
137
125
|
});
|
|
138
|
-
}
|
|
126
|
+
};
|
|
139
127
|
|
|
140
|
-
|
|
128
|
+
const createMutation = defaultOptions => {
|
|
141
129
|
const getKey = () => defaultOptions.mutationKey;
|
|
142
130
|
|
|
143
|
-
return Object.assign(
|
|
131
|
+
return Object.assign(withMiddleware(reactQuery.useMutation, defaultOptions, 'mutations'), {
|
|
144
132
|
getKey,
|
|
145
133
|
mutationFn: defaultOptions.mutationFn
|
|
146
134
|
});
|
|
147
|
-
}
|
|
135
|
+
};
|
|
148
136
|
|
|
149
|
-
exports.createImmutableQuery = createImmutableQuery;
|
|
150
137
|
exports.createInfiniteQuery = createInfiniteQuery;
|
|
151
138
|
exports.createMutation = createMutation;
|
|
152
139
|
exports.createQuery = createQuery;
|